2023-12-09 18:42:21 +08:00
< p > Given a string < code > s< / code > , return < em > the < / em > < span data-keyword = "lexicographically-smaller-string" > < em > lexicographically smallest< / em > < / span > < span data-keyword = "subsequence-string" > < em > subsequence< / em > < / span > < em > of< / em > < code > s< / code > < em > that contains all the distinct characters of< / em > < code > s< / code > < em > exactly once< / em > .< / p >
2022-03-27 18:35:17 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > s = " bcabc"
< strong > Output:< / strong > " abc"
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > s = " cbacdcbc"
< strong > Output:< / strong > " acdb"
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = s.length < = 1000< / code > < / li >
< li > < code > s< / code > consists of lowercase English letters.< / li >
< / ul >
< p > < / p >
< strong > Note:< / strong > This question is the same as 316: < a href = "https://leetcode.com/problems/remove-duplicate-letters/" target = "_blank" > https://leetcode.com/problems/remove-duplicate-letters/< / a >