Given an array of stone weights, repeatedly smash the two heaviest stones together and return the minimum possible final stone weight. This problem reduces to splitting the stones into two subsets with minimum difference.
stones = array of stone weights
minimum possible final stone weight
Example 1:
Input:
stones = [2,7,4,1,8,1]
Output:
1
Explanation:
A near-even partition leaves a stone of weight 1.
Example 2:
Input:
stones = [31,26,33,21,40]
Output:
5
Explanation:
The best achievable difference is 5.