Final Weight Under Heaviest-Pair Smashing. Repeatedly take the two heaviest remaining stones. Equal weights both disappear; unequal weights x<y are replaced by one stone of weight y-x.
### Problem
Repeatedly take the two heaviest remaining stones. Equal weights both disappear; unequal weights x<y are replaced by one stone of weight y-x. Return the last weight, or 0 when no stone remains.
```cpp
class Solution {
public:
int lastStoneWeight(vector<int>& stones);
};
```
### Examples
**Example 1:**
```text
Input: stones = [6,3,2]
Output: 1
Explanation:6 and3 become3;3 and2 then become1.
```
**Example 2:**
```text
Input: stones = [4,4,2,2]
Output: 0
Explanation: The two4s disappear, then the two2s disappear.
```
### Constraints
- There are at least 1 and at most 30 stones.
- Each weight is an integer in `[1,1000]`.
### Contract considerations
The heaviest-pair choice is mandatory, rather than a decision to optimize.
```hint Read the boundary condition
Does each turn use the original heaviest pair or the stones that remain after the preceding smash?
```
### Boundary reminders
The heaviest-pair choice is mandatory, rather than a decision to optimize.
Overview: Final Weight Under Heaviest-Pair Smashing. Repeatedly take the two heaviest remaining stones. Equal weights both disappear; unequal weights x<y are replaced by one stone of weight y-x.
Repeatedly take the two heaviest remaining stones. Equal weights both disappear; unequal weights x<y are replaced by one stone of weight y-x. Return the last weight, or 0 when no stone remains.
class Solution {
public:
int lastStoneWeight(vector<int>& stones);
};