Skip to content

Commit 7d14df8

Browse files
committed
minimum_string_length_after_balanced_removals.rs
1 parent 8082a62 commit 7d14df8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
impl Solution {
2+
pub fn min_length_after_removals(s: String) -> i32 {
3+
let mut ct: i32 = 0;
4+
for c in s.chars() {
5+
match c {
6+
'a' => ct += 1,
7+
'b' => ct -= 1,
8+
_ => {}
9+
}
10+
}
11+
ct.abs()
12+
}
13+
}

0 commit comments

Comments
 (0)