Maximum Number of Words You Can Type LeetCode solution in Java

1
class Solution {
2
public int canBeTypedWords(String text, String brokenLetters) {
3
int count = 1;
4
boolean isBad = false;
5
for (char c : text.toCharArray()) {
6
if (c == ' ') {
7
isBad = false;
8
count++;
9
} else {
10
if (!isBad && brokenLetters.indexOf(c) != -1) {
11
isBad = true;
12
count--;
13
}
14
}
15
}
16
return count;
17
}
18
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0