3816. Lexicographically Smallest String After Deleting Duplicate Characters Hard
1/**
2 * [3816] Lexicographically Smallest String After Deleting Duplicate Characters
3 *
4 * You are given a string s that consists of lowercase English letters.
5 * You can perform the following operation any number of times (possibly zero times):
6 *
7 * Choose any letter that appears at least twice in the current string s and delete any one occurrence.
8 *
9 * Return the <span data-keyword="lexicographically-smaller-string">lexicographically smallest</span> resulting string that can be formed this way.
10 *
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">s = "aaccb"</span>
14 * Output: <span class="example-io">"aacb"</span>
15 * Explanation:
16 * We can form the strings "acb", "aacb", "accb", and "aaccb". "aacb" is the lexicographically smallest one.
17 * For example, we can obtain "aacb" by choosing 'c' and deleting its first occurrence.
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">s = "z"</span>
22 * Output: <span class="example-io">"z"</span>
23 * Explanation:
24 * We cannot perform any operations. The only string we can form is "z".
25 * </div>
26 *
27 * Constraints:
28 *
29 * 1 <= s.length <= 10^5
30 * s contains lowercase English letters only.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/lexicographically-smallest-string-after-deleting-duplicate-characters/
36// discuss: https://leetcode.com/problems/lexicographically-smallest-string-after-deleting-duplicate-characters/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn lex_smallest_after_deletion(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_3816() {
54 }
55}
56Back
© 2026 bowen.ge All Rights Reserved.