Skip to content

Commit 1699b26

Browse files
add 2062
1 parent 0856174 commit 1699b26

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2062|[Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2062.java) ||Easy||
1112
|2058|[Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2058.java) ||Medium||
1213
|2057|[Smallest Index With Equal Value](https://leetcode.com/problems/smallest-index-with-equal-value/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2057.java) ||Easy||
1314
|2055|[Plates Between Candles](https://leetcode.com/problems/plates-between-candles/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2055.java) ||Medium||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.Arrays;
4+
import java.util.HashSet;
5+
import java.util.Set;
6+
7+
public class _2062 {
8+
public static class Solution1 {
9+
public int countVowelSubstrings(String word) {
10+
int count = 0;
11+
Set<Character> vowels = new HashSet<>(Arrays.asList('a', 'e', 'i', 'o', 'u'));
12+
Set<Character> window = new HashSet<>();
13+
for (int i = 0; i < word.length(); i++) {
14+
window.clear();
15+
if (vowels.contains(word.charAt(i))) {
16+
window.add(word.charAt(i));
17+
for (int j = i + 1; j < word.length(); j++) {
18+
if (!vowels.contains(word.charAt(j))) {
19+
break;
20+
} else {
21+
window.add(word.charAt(j));
22+
if (window.size() == 5) {
23+
count++;
24+
}
25+
}
26+
}
27+
}
28+
}
29+
return count;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)