Search
⌘K

Leetcode 316. Remove Duplicate Letters

Remove duplicate letters from s so each character appears exactly once and the resulting string is the smallest possible in lexicographic order. This is solved by a greedy monotonic-stack strategy that keeps one copy of each letter while using last-occurrence information (and a visited set) to decide safe removals.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.