Easy to understand: heap + hashmap; 90% O(N∗Logn)
We use heap to get the smallest letter fast and store the indices in the dictionary.\n Describe your approach to solving the problem. \n\n# Complexity\n- Time c
We use heap to get the smallest letter fast and store the indices in the dictionary.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N\u2217Logn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def clearStars(self, s: str) -> str:\n        res = list(s)\n        h = [] # init. heap\n        idx = defaultdict(list) # hashmap to store indices\n        for i in range(len(s)):\n            if s[i] == "*": \n                ltr = heapq.heappop(h) # get ltr\n                i_del = idx[ltr].pop() # get ind\n                res[i_del] = "" # del ltr \n                res[i] = "" # del * symbol\n            else:\n                heapq.heappush(h, s[i]) # save ltr\n                idx[s[i]].append(i) # save ind\n        return "".join(res)\n```
['Hash Table', 'Heap (Priority Queue)', 'Python3']