You are given an array of integers stones where stones[i] is the weight of the i-th stone.
On each turn, choose the two heaviest stones and smash them together. Suppose the stones have weights x and y with x <= y:
- If
x == y, both stones are destroyed. - If
x != y, the stone of weightxis destroyed, and the stone of weightynow has weighty - x.
At the end of the game, there is at most one stone left. Return the weight of the last remaining stone, or 0 if there are no stones left.