MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / make_fancy_string

Function make_fancy_string

1957-make_fancy_string.rs:11–29  ·  view source on GitHub ↗

1957 https://leetcode-cn.com/problems/delete-characters-to-make-fancy-string/ leeetcode leetcode aaabaaaa aabaa aab aab

(s: String)

Source from the content-addressed store, hash-verified

9// aaabaaaa aabaa
10// aab aab
11pub fn make_fancy_string(s: String) -> String {
12 let mut flag_c = '*';
13 let mut counter = 1;
14 let mut res_str = String::from("");
15 for c in s.chars() {
16 if c != flag_c {
17 flag_c = c;
18 counter = 1;
19 } else {
20 counter += 1;
21 }
22 if counter > 2 {
23 continue;
24 } else {
25 res_str.push(c);
26 }
27 }
28 res_str
29}

Callers 1

mainFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected