DE SHAW Online Round Question

Given an array of positive integers, each of which represent the number of litres of water in that particular bucket, we have to make the litres of water in every bucket equal.
We are allowed to do two types of operations any number of times:
1) We can altogether remove a bucket from the sequence
2) We can remove some water from a bucket
We have to tell what is the minimum number of litres removed to make all buckets have the same amount of water.
Eg.
Input:
1 2 3
Output:
2
Explanation:
We remove bucket 1 and remove 1 liter from Bucket 3, so total water removed is 2 liter (the amount of water in the bucket removed gets added to the total water removed).
Any idea on what would be a possible solution to this?
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Open Chat in New Window
Open Chat in New Window