gary@interview:~/interview/coding/1046-last-stone-….md$
$ cat ./coding/1046-last-stone-weight.md
[Coding]

1046. Last Stone Weight

────────────────────────────────────────────────────────────

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
265. Paint House II256. Paint House143. Reorder List1762. Buildings With an Ocean View
← cd ../codingcd ~