#316
Remove Duplicate Letters
specialist · 825 · lc medium +31 · verified · 52.9% accepted · 9,278 likes · top 43%
Description
Given a string s, remove duplicate characters so that each character appears exactly once. Among all valid results, return the lexicographically smallest one.
Example 1:
Input: s = "bcabc"
Output: "abc"
Example 2:
Input: s = "cbacdcbc"
Output: "acdb"
Code
1
2
3