34. Heavier Stones
Easy
In each round, choose the two stones with the greatest weight. If they are equal, both disappear; otherwise, the difference between their weights becomes a new stone. Return the weight of the last stone, or 0 if none remain.
Example 1
Input: pesos = [3, 8, 4, 8]
Output: 1
Explanation: The two stones with weight 8 cancel each other out; then, 4 and 3 leave a stone with weight 1.
Example 2
Input: pesos = [6, 6]
Output: 0
Constraints
- 0 <= pesos.length <= 10^4
- 1 <= pesos[i] <= 10^4
Heap
Saved in this browser
Caso 1
pesos =
[3,8,4,8]
Expected =
1
Caso 2
pesos =
[6,6]
Expected =
0
Run checks these 2 cases. Submit runs all 6, including hidden ones.