Skip to content

Commit bcde8d2

Browse files
committed
src/bin/maximum-number-of-balloons.rs
1 parent 286e0ea commit bcde8d2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/bin/maximum-number-of-balloons.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![allow(dead_code, unused, unused_variables, non_snake_case)]
2+
3+
fn main() {}
4+
5+
struct Solution;
6+
7+
impl Solution {
8+
pub fn max_number_of_balloons(text: String) -> i32 {
9+
let mut v = [0; 5];
10+
for i in text.bytes() {
11+
match i {
12+
b'b' => v[0] += 1,
13+
b'a' => v[1] += 1,
14+
b'l' => v[2] += 1,
15+
b'o' => v[3] += 1,
16+
b'n' => v[4] += 1,
17+
_ => {}
18+
}
19+
}
20+
21+
v[0].min(v[1]).min(v[2] / 2).min(v[3] / 2).min(v[4])
22+
}
23+
}

0 commit comments

Comments
 (0)