Free written solutionSmallest Subsequence of Distinct Characters (LeetCode 1081): Solution and Explanation
Return the lexicographically smallest subsequence of s that uses every distinct letter exactly once. For bcabc the answer is abc, and for cbacdcbc it is acdb.
Read the intuition, approach, code and complexity →