1
+ /**
2
+ * @param {string } word
3
+ * @param {number } k
4
+ * @return {number }
5
+ */
6
+ var countVowelSubstrings = function ( word , k ) {
7
+
8
+ } ;
9
+
10
+ const example1 = countVowelSubstrings ( 'aeiouu' , 0 ) ; // 2
11
+ const example2 = countVowelSubstrings ( 'unicornarihan' , 0 ) ; // 0
12
+ const example3 = countVowelSubstrings ( 'cuaieuouac' , 0 ) ; // 7
13
+ const example4 = countVowelSubstrings ( 'aeioqq' , 1 ) ; // 0
14
+ const example5 = countVowelSubstrings ( 'aeiou' , 0 ) ; // 1
15
+ const example6 = countVowelSubstrings ( 'ieaouqqieaouqq' , 1 ) ; // 3
16
+
17
+ console . log ( example1 ) ;
18
+ console . log ( example2 ) ;
19
+ console . log ( example3 ) ;
20
+ console . log ( example4 ) ;
21
+ console . log ( example5 ) ;
22
+ console . log ( example6 ) ;
23
+
24
+ // var countVowelSubstrings = function(word, k) {
25
+ // return solve(word, k) - solve(word, k + 1);
26
+ // };
27
+
28
+ // var solve = function(word, k) {
29
+ // const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
30
+ // let vowelMap = new Map();
31
+ // let result = 0;
32
+ // let consonants = 0;
33
+ // let left = 0;
34
+
35
+ // for (let right = 0; right < word.length; right++) {
36
+ // let char = word[right];
37
+
38
+ // if (vowels.has(char)) {
39
+ // vowelMap.set(char, (vowelMap.get(char) || 0) + 1);
40
+ // } else {
41
+ // consonants++;
42
+ // }
43
+
44
+ // while (vowelMap.size === 5 && consonants >= k) {
45
+ // result += word.length - right;
46
+ // let leftChar = word[left];
47
+
48
+ // if (vowels.has(leftChar)) {
49
+ // vowelMap.set(leftChar, vowelMap.get(leftChar) - 1);
50
+ // if (vowelMap.get(leftChar) === 0) {
51
+ // vowelMap.delete(leftChar);
52
+ // }
53
+ // } else {
54
+ // consonants--;
55
+ // }
56
+ // left++;
57
+ // }
58
+ // }
59
+
60
+ // return result;
61
+ // }
0 commit comments