You are given an array of integers representing the weights of stones. In a game, two heaviest stones are smashed together. If both are of equal weight, they are destroyed. If their weights differ, the stone of lesser weight is destroyed, and the heavier stone's new weight is the difference of the two weights. The game continues until at most one stone remains. Return the weight of the last remaining stone. If no stones are left, return 0.
Click Run to execute sample tests.