Easy Python Stack 100%-100%
python\nclass Solution:\n    def smallestSubsequence(self, S):\n        indexLast = {S[i]: i for i in range(len(S))}\n        stack = []\n        for i in range
```python\nclass Solution:\n    def smallestSubsequence(self, S):\n        indexLast = {S[i]: i for i in range(len(S))}\n        stack = []\n        for i in range(len(S)):\n            if S[i] in stack: continue\n\n            while stack and stack[-1] > S[i] and i < indexLast[stack[-1]]:\n                stack.pop()\n            stack.append(S[i])\n            \n        return "".join(stack)\n```
[]