Count Vowel Substrings of a String LeetCode solution in Java

1
class Solution {
2
public int countVowelSubstrings(String word) {
3
int vow = 0;
4
int n = word.length();
5
Set<Character> set = new HashSet<>();
6
for (int i = 0; i < n - 4; i++) {
7
set.clear();
8
for (int j = i; j < n; j++) {
9
char ch = word.charAt(j);
10
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
11
set.add(ch);
12
if (set.size() == 5) vow++;
13
} else break;
14
}
15
}
16
return vow;
17
}
18
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0