You have stones with weights. Each turn, pick two stones and smash them. If equal, both destroyed. If not, the lighter one is destroyed and the heavier one becomes . Return the minimum possible weight of the last stone (or 0 if all destroyed).
This looks like a simulation problem, but simulating all possible smash orders is exponential. There's a mathematical observation that converts this to subset sum. Before reading on, think about what happens when you smash all stones. What's the final result as the original weights?