[Python] dict of list of indexes (beats 100%) O(N)
\n"""\nSupport here dict of indexes, to fast replace smallest character\n\nTC: O(N)\nSC: O(N)\n"""\nclass Solution:\n    def clearStars(self, s: str) -> str:\n 
```\n"""\nSupport here dict of indexes, to fast replace smallest character\n\nTC: O(N)\nSC: O(N)\n"""\nclass Solution:\n    def clearStars(self, s: str) -> str:\n        a = []\n        d = defaultdict(list)\n\n        for ch in s:\n            if ch != \'*\':\n                d[ch].append(len(a))\n                a.append(ch)\n                continue\n\n            m = min(d)\n\n            i = d[m].pop()\n            a[i] = \'~\'\n            if len(d[m]) == 0:\n                del d[m]\n\n        return \'\'.join(filter(lambda ch: ch != \'~\', a))\n```
['Python']