Using Heap | Python
Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n    def clearStars(self, s: str) -> str:\n        heap = []\n 
# Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n    def clearStars(self, s: str) -> str:\n        heap = []\n        for i,c in enumerate(s):\n            if c==\'*\':\n                heappop(heap)\n            else:\n                heappush(heap,(c,-i))\n        \n        ans = [\'\']*len(s)\n        while heap:\n            char,i = heappop(heap)\n            ans[-i] = char\n            \n        return \'\'.join(ans)\n            \n        \n```
['String', 'Heap (Priority Queue)', 'Python', 'Python3']