import heapq
classSolution:deflastStoneWeight(self, stones: List[int])->int: stones =[-i for i in stones] heapify(stones)whilelen(stones)>=2: y =-heappop(stones) x =-heappop(stones)if x == y:continue heappush(stones,-(y-x))return-stones[0]iflen(stones)==1else0