While the heap contains more than one stone:
a. Remove the two largest stones from the heap (the two max elements).
b. If the weights of the stones are not equal, insert the absolute difference back into the heap.
If the heap is empty, return 0.
Otherwise, return the weight of the last remaining stone (the only element left in the heap).