Understand the problem
Restate the problem precisely. Interviewers reward candidates who pause, define the contract, and name the guarantees before coding.
You are given an array of integers `stones` where `stones[i]` is the weight of the `i`-th stone. We are playing a game with the stones. On each turn, we choose the *heaviest two* stones and smash them together. Suppose the heaviest two have weights `x` and `y` with `x ≤ y`. The result of this smash is: if `x == y`, both are destroyed; otherwise, the stone of weight `x` is destroyed and the stone of weight `y` becomes `y - x`. At the end of the game, at most one stone is left. Return the smallest possible weight of the last remaining stone (or 0 if none).
Once you've drafted a response, click Submit for AI review and a senior engineer will critique your reasoning.