python heapq
\n"""\nChoose two heaviest stones and smash them together\n\nx==y: destroyed\nx != y, new weight is difference, return weight of stome\n\nApproach:\nuse max hea
```\n"""\nChoose two heaviest stones and smash them together\n\nx==y: destroyed\nx != y, new weight is difference, return weight of stome\n\nApproach:\nuse max heap, get difference\n"""\nimport heapq\n\nclass Solution:\n    def lastStoneWeight(self, stones: List[int]) -> int:\n        stones = [-x for x in stones]\n        heapq.heapify(stones)\n        \n        while len(stones) > 1:\n            stone1 = -(heapq.heappop(stones))\n            stone2 = -(heapq.heappop(stones))\n            \n            if stone1 == stone2: continue\n            heapq.heappush(stones,-(abs(stone1-stone2)))\n            \n        if len(stones) == 0: return 0\n        return -(heapq.heappop(stones))\n```
['Heap (Priority Queue)', 'Python', 'Python3']