Skip to content

Commit 607312b

Browse files
committed
Runtime: 0 ms (Top 100.0%) | Memory: 2.10 MB (Top 91.67%)
1 parent c687ec5 commit 607312b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Runtime: 0 ms (Top 100.0%) | Memory: 2.10 MB (Top 91.67%)
2+
3+
impl Solution {
4+
pub fn can_be_typed_words(text: String, broken_letters: String) -> i32 {
5+
let broken_hash = broken_letters
6+
.into_bytes()
7+
.iter()
8+
.fold([false; 26], |mut acc, &b| {
9+
acc[(b - b'a') as usize] = true;
10+
acc
11+
});
12+
13+
text.split_ascii_whitespace()
14+
.filter(|&s| {
15+
s.as_bytes()
16+
.iter()
17+
.all(|&b| !broken_hash[(b - b'a') as usize])
18+
})
19+
.count() as _
20+
}
21+
}

0 commit comments

Comments
 (0)