Little Billy has several boxes full of candies in front of him. However he doesn't like that these boxes don't each contain the same number of candies, so he decides to eat some of the candies until they do.
Specifically, little Billy follows this algorithm:
Step 1: He calculates min, the minimum number of candies in a box, and max, the maximum number of candies in a box. If these numbers are equal the algorithm ends, otherwise continue with step 2.
Step 2: He arbitrarily chooses a box with max candies and eats min candies from it, then he returns to step 1.
You will be given a int[] candies. The ith element of candies is equal to the number of candies in the ith box. Return the number of candies remaining in each of the boxes after the algorithm described above is executed.
|