Skip to content

Commit 6a8d8e2

Browse files
committed
Runtime: 0 ms (Top 100.0%) | Memory: 2.10 MB (Top 81.82%)
1 parent 214e1c5 commit 6a8d8e2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Runtime: 0 ms (Top 100.0%) | Memory: 2.10 MB (Top 81.82%)
2+
3+
impl Solution {
4+
pub fn make_good(s: String) -> String {
5+
s.chars().fold(String::new(), |mut rez, c2| {
6+
match (rez.pop(), c2) {
7+
(None, c2) => c2.to_string(),
8+
(Some(c1), c2)
9+
if c1 != c2 && c1.to_lowercase().eq(c2.to_lowercase())
10+
=> rez,
11+
(Some(c1), c2) => rez + &c1.to_string() + &c2.to_string(),
12+
}
13+
})
14+
}
15+
}

0 commit comments

Comments
 (0)