Lexicographically Smallest String After Deleting Duplicate Characters
You are given a string s that consists of lowercase English letters.
You can perform the following operation any number of times, possibly zero times:
- Choose any letter that appears at least twice in the current string
sand delete any one occurrence.
Return the lexicographically smallest resulting string that can be formed this way.
Example 1
Input
s = "aaccb"Output
"aacb"We can form the strings
"acb", "aacb", "accb", and "aaccb"; "aacb" is the lexicographically smallest one.Example 2
Input
s = "z"Output
"z"We cannot perform any operations, so the only string we can form is
"z".Constraints
- 1 <= s.length <= 10^5
- s contains lowercase English letters only.