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