316. Remove Duplicate Letters Medium

@problem@discussion
#String#Stack#Greedy#Monotonic Stack



1/**
2 * [316] Remove Duplicate Letters
3 *
4 * Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.
5 *  
6 * Example 1:
7 * 
8 * Input: s = "bcabc"
9 * Output: "abc"
10 * 
11 * Example 2:
12 * 
13 * Input: s = "cbacdcbc"
14 * Output: "acdb"
15 * 
16 *  
17 * Constraints:
18 * 
19 * 	1 <= s.length <= 10^4
20 * 	s consists of lowercase English letters.
21 * 
22 *  
23 * Note: This question is the same as 1081: <a href="https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/" target="_blank">https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/</a>
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/remove-duplicate-letters/
29// discuss: https://leetcode.com/problems/remove-duplicate-letters/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn remove_duplicate_letters(s: String) -> String {
35        String::new()
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_316() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.