Smash the Heaviest Stones
Asked at FactSet · Coding Questions · Difficulty: Easy
A pile of stones is reduced by repeated smashing. Each round, take the two heaviest stones and smash them together: if they weigh the same, both disappear; otherwise the lighter one disappears and the heavier one keeps the difference of the two weights. The process ends when at most one stone remains. Report the weight of the stone that is left.
Loading the problem…