You have stones with positive integer weights. Each turn, smash the two heaviest together: equal weights → both destroyed; otherwise the heavier survives with the difference. Return the weight of the last stone, or 0 if none remain.
Input: one line of space-separated integers. Output: the final weight (or 0).
2 7 4 1 8 1
1
8&7→1, 4&2→2, 2&1→1, 1&1→0 leaves 1.
1
1
Run your code against the sample tests, or Submit to run the full suite.