1046. Last Stone Weight
Содержание
class Solution:
def lastStoneWeight(self, stones: List[int]) -> int:
h = [-x for x in stones]
heapify(h)
while len(h) > 1:
y, x = -heappop(h), -heappop(h)
if x != y:
heappush(h, x - y)
return 0 if not h else -h[0]