3170. Lexicographically Minimum String After Removing Stars
3170. Lexicographically Minimum String After Removing Stars
Description
You are given a string s
. It may contain any number of '*'
characters. Your task is to remove all '*'
characters.
While there is a '*'
, do the following operation:
- Delete the leftmost
'*'
and the smallest non-'*'
character to its left. If there are several smallest characters, you can delete any of them.
Return the lexicographically smallest resulting string after removing all '*'
characters.
Example 1:
1 | Input: s = "aaba*" |
Example 2:
1 | Input: s = "abc" |
Constraints:
1 <= s.length <= 10^5
s
consists only of lowercase English letters and'*'
.- The input is generated such that it is possible to delete all
'*'
characters.
Hints/Notes
- Weekly Contest 400
Solution
Language: C++
1 | class Solution { |