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