$ cat ./coding/1046-last-stone-weight.md
[Coding]
1046. Last Stone Weight
────────────────────────────────────────────────────────────
class Solution:
def lastStoneWeight(self, stones: List[int]) -> int:
heap = []
for stone in stones:
heapq.heappush(heap, -1 * stone)
while len(heap) > 1:
first = heapq.heappop(heap)
second = heapq.heappop(heap)
if first != second:
heapq.heappush(heap, first - second)
if len(heap) == 0:
return 0
else:
return -1 * heap[0]
--tags#Design#Heap
$ ls ./coding/ | grep -v 1046-last-stone-weight