Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def lastStoneWeight(self, stones: List[int]) -> int:
- stones = [-s for s in stones]
- heapq.heapify(stones)
- while (len(stones) > 1):
- x = heapq.heappop(stones)
- y = heapq.heappop(stones)
- if x!=y :
- heapq.heappush(stones, x - y)
- return -stones[0] if len(stones) > 0 else 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement