Easy Python solution with stack & set
\tclass Solution:\n\t\tdef smallestSubsequence(self, s: str) -> str:\n\t\t\tnew = {}\n\t\t\tfor i in range(len(s)):\n\t\t\t\tnew[s[i]]=i\n\t\t\tstak,seen=[],set
\tclass Solution:\n\t\tdef smallestSubsequence(self, s: str) -> str:\n\t\t\tnew = {}\n\t\t\tfor i in range(len(s)):\n\t\t\t\tnew[s[i]]=i\n\t\t\tstak,seen=[],set()\n\t\t\tfor i in range(len(s)):\n\t\t\t\tif s[i] not in seen:\n\t\t\t\t\twhile stak and new[stak[-1]]>i and stak[-1]>s[i]:\n\t\t\t\t\t\tseen.remove(stak[-1])\n\t\t\t\t\t\tstak.pop()\n\t\t\t\t\tstak.append(s[i])\n\t\t\t\t\tseen.add(s[i])\n\t\t\treturn "".join(stak)\n
[]