Approach hintTry it first, then revealHide
Keep the stones in a max-heap; repeatedly pop the two heaviest and push back their difference when it is non-zero.
Keep the stones in a max-heap; repeatedly pop the two heaviest and push back their difference when it is non-zero.