Untitled
unknown
plain_text
9 months ago
543 B
3
Indexable
public static long countVietnameseLetters(String input) {
List<String> telexTexts =List.of("aw", "aa", "dd", "ee", "oo", "ow", "w");
long count = 0;
for (int i = 0; i < input.length(); i++) {
if (i + 1 <= input.length() && telexTexts.contains(input.substring(i, i + 1))) {
count++;
} else if (i + 2 <= input.length() && telexTexts.contains(input.substring(i, i + 2))) {
count++;
i++;
}
}
return count;
}Editor is loading...
Leave a Comment