Question: JAVA!! Equal Price A shop in HackerLand contains n items where the price of the th item is price ( l ] , In one
JAVA!! Equal Price
A shop in HackerLand contains n items where the price of the th item is pricel In one operation, the price of any one item can be increased or decreased by
Given q queries denoted by the array queryl, find the minimum number of operations required to make the price of all items equal to each queryll q
Note: All queries are independent of each other, ie the original price of items is restored after the completion of each query.
Example:
Consider n q pricel queryD
query The number of operations required tomake the price of all elements equal to Total number ofoperations
query operations required
query operations required
query operations required
The answer is
Function Description
Complete the function countMinimumOperations in the editor below.
countMinimumOperations has the following parameters:
int pricen: the original prices of each item int querylq: the queries
Returns
longintq: the answers to the queries in their order of input
Constraints
n
pricelldeg
q
querylldeg
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
