diff options
Diffstat (limited to 'other/make_string_great.rs')
-rw-r--r-- | other/make_string_great.rs | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/other/make_string_great.rs b/other/make_string_great.rs deleted file mode 100644 index 76a28a2..0000000 --- a/other/make_string_great.rs +++ /dev/null @@ -1,21 +0,0 @@ -struct Solution; - -impl Solution { - pub fn make_good(s: String) -> String { - let diff_cases = |c1: char, c2: char| c1.to_ascii_lowercase() == c2.to_ascii_lowercase() && c1 != c2; - s.chars().into_iter().fold(Vec::with_capacity(s.len()), |mut v: Vec<char>, c| { - match v.last() { - Some(prev_c) if diff_cases(c, *prev_c) => { - v.pop(); - } - _ => v.push(c) - } - v - }).iter().collect() - } -} - -fn main() { - let s = "leEeetcode".to_string(); - print!("{}", Solution::make_good(s)); -} |