Smash the Stones
Each turn, take the two heaviest stones with weights . If both are destroyed; otherwise a stone of weight remains. Return the weight of the last stone, or 0 if none remain.
Examples
EXAMPLE WALKTHROUGHclassic
A guided view of the published example, not a trace of your code.
INPUT
[[2,7,4,1,8,1]]TASKsmash_the_stones()
EXPECTED OUTPUT
1Start with the input values shown in this example.
Example 1 of 3
Input: stones = [2,7,4,1,8,1]
Output: 1
Explanation: classic
Input: stones = [1]
Output: 1
Explanation: single
Input: stones = [3,3]
Output: 0
Explanation: both destroyed
Hint 1
Use a max-heap (in Python, push negated weights onto heapq).