Equal Piles
Given a list of integers nums
, you can perform the following operation: pick the largest integer in nums
and turn it into the second largest number.
Return the minimum number of operations required to make all integers the same in the list.
Constraints
n ≤ 100,000
wheren
is the length ofnums
https://binarysearch.com/problems/Equal-Piles
Examples
Example 1
Input
- nums =
[4, 8, 2]
Output
- answer =
3
Explanation
- Turn
8
to4
to get[4, 4, 2]
- Turn
4
to2
to get[2, 4, 2]
- Turn
4
to2
to get[2, 2, 2]
Leave a comment