Two Appraoches :Heapq and Sorting
Heap  Approach : TC : (NLogN)\n\nclass Solution:\n    def lastStoneWeight(self, stones: List[int]) -> int:\n        list1=[-x for x in stones]\n        while le
# Heap  Approach : TC : (NLogN)\n```\nclass Solution:\n    def lastStoneWeight(self, stones: List[int]) -> int:\n        list1=[-x for x in stones]\n        while len(list1)>1:\n            heapq.heapify(list1)\n            a,b=heapq.heappop(list1),heapq.heappop(list1)\n            heapq.heappush(list1,-(abs(a-b)))\n        return abs(list1[0])\n```\n# Sorting Approach ,TC:---->N*(N*LogN)\n```\nclass Solution:\n    def lastStoneWeight(self, stones: List[int]) -> int:\n        while len(stones)>1:\n            stones.sort()\n            a,b=stones.pop(),stones.pop()\n            stones.append(abs(a-b))\n        return stones[0]\n````\n# please upvote me it would encourage me alot\n
['Python']