amounts[i] candies in box i. Each box is to be shared equally among three kids, so every box must end up holding a multiple of three (zero counts).
In one step you may add a single candy to any box or take a single candy out of any box. Return the smallest number of steps.amounts=[5, 9, 7] → 2
5 → 6 (one step), 9 is already a multiple of 3, 7 → 6 (one step). Two in total.
amounts=[1, 1, 2] → 3
Each number is 1 away from the nearest multiple of three (0 or 3), so 3 steps in total.
amounts=[5, 9, 7]
2
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.