106. Last Stone Weight

At each step, smash the two heaviest stones. If the difference is > 0, a stone with that weight difference remains. Return the weight of the last stone.
Example 1
Input: stones = [1]
Output: 1
Explanation: One stone — its weight is the answer.
Example 2
Input: stones = [2,7,4,1,8,1]
Output: 1
Explanation: After a series of collisions, a stone of weight 1 remains.
arrayseasyheap
JavaScript
Loading...
Line 1, Char 1