3170. Lexicographically Minimum String After Removing Stars Medium

@problem@discussion
#Hash Table#String#Stack#Greedy#Heap (Priority Queue)



1/**
2 * [3170] Lexicographically Minimum String After Removing Stars
3 *
4 * You are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters.
5 * While there is a '*', do the following operation:
6 * 
7 * 	Delete the leftmost '*' and the smallest non-'*' character to its left. If there are several smallest characters, you can delete any of them.
8 * 
9 * Return the <span data-keyword="lexicographically-smaller-string">lexicographically smallest</span> resulting string after removing all '*' characters.
10 *  
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">s = "aaba*"</span>
14 * Output: <span class="example-io">"aab"</span>
15 * Explanation:
16 * We should delete one of the 'a' characters with '*'. If we choose s[3], s becomes the lexicographically smallest.
17 * </div>
18 * <strong class="example">Example 2:
19 * <div class="example-block">
20 * Input: <span class="example-io">s = "abc"</span>
21 * Output: <span class="example-io">"abc"</span>
22 * Explanation:
23 * There is no '*' in the string.<!-- notionvc: ff07e34f-b1d6-41fb-9f83-5d0ba3c1ecde -->
24 * </div>
25 *  
26 * Constraints:
27 * 
28 * 	1 <= s.length <= 10^5
29 * 	s consists only of lowercase English letters and '*'.
30 * 	The input is generated such that it is possible to delete all '*' characters.
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/
36// discuss: https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn clear_stars(s: String) -> String {
42        String::new()
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_3170() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.