Maximum Number of Words You Can Type LeetCode solution in Rust

1
impl Solution {
2
pub fn can_be_typed_words(text: String, broken_letters: String) -> i32 {
3
let broken_hash = broken_letters
4
.into_bytes()
5
.iter()
6
.fold([false; 26], |mut acc, &b| {
7
acc[(b - b'a') as usize] = true;
8
acc
9
});
10

11
text
12
.split_ascii_whitespace()
13
.filter(|&s| {
14
s.as_bytes()
15
.iter()
16
.all(|&b| !broken_hash[(b - b'a') as usize])
17
})
18
.count() as _
19
}
20
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0