1957. Delete Characters to Make Fancy String Easy
1/**
2 * [1957] Delete Characters to Make Fancy String
3 *
4 * A fancy string is a string where no three consecutive characters are equal.
5 * Given a string s, delete the minimum possible number of characters from s to make it fancy.
6 * Return the final string after the deletion. It can be shown that the answer will always be unique.
7 *
8 * Example 1:
9 *
10 * Input: s = "le<u>e</u>etcode"
11 * Output: "leetcode"
12 * Explanation:
13 * Remove an 'e' from the first group of 'e's to create "leetcode".
14 * No three consecutive characters are equal, so return "leetcode".
15 *
16 * Example 2:
17 *
18 * Input: s = "<u>a</u>aab<u>aa</u>aa"
19 * Output: "aabaa"
20 * Explanation:
21 * Remove an 'a' from the first group of 'a's to create "aabaaaa".
22 * Remove two 'a's from the second group of 'a's to create "aabaa".
23 * No three consecutive characters are equal, so return "aabaa".
24 *
25 * Example 3:
26 *
27 * Input: s = "aab"
28 * Output: "aab"
29 * Explanation: No three consecutive characters are equal, so return "aab".
30 *
31 *
32 * Constraints:
33 *
34 * 1 <= s.length <= 10^5
35 * s consists only of lowercase English letters.
36 *
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/delete-characters-to-make-fancy-string/
41// discuss: https://leetcode.com/problems/delete-characters-to-make-fancy-string/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46 pub fn make_fancy_string(s: String) -> String {
47 String::new()
48 }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_1957() {
59 }
60}
61
Back
© 2025 bowen.ge All Rights Reserved.