Skip to content

Commit 02a3ca7

Browse files
BarklimBarklim
Barklim
authored and
Barklim
committed
Create 3306.js
1 parent 0156d6a commit 02a3ca7

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

example/Dayly/2062.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @param {string} word
3+
* @return {number}
4+
*/
5+
var countVowelSubstrings = function(word) {
6+
7+
};
8+
9+
const example1 = countVowelSubstrings('aeiouu'); // 2
10+
const example2 = countVowelSubstrings('unicornarihan'); // 0
11+
const example3 = countVowelSubstrings('cuaieuouac'); // 7
12+
13+
console.log(example1);
14+
console.log(example2);
15+
console.log(example3);
16+
17+
// var countVowelSubstrings = function(word) {
18+
// return solve(word, 5) - solve(word, 4)
19+
// };
20+
21+
// var solve = function(word, n) {
22+
// const vowels = new Set(['a', 'e', 'i', 'o', 'u'])
23+
// const freqMap = new Map()
24+
// let l = 0, r = 0, result = 0
25+
26+
// while (r < word.length) {
27+
// if (vowels.has(word[r])) {
28+
// freqMap.set(word[r], (freqMap.get(word[r]) || 0) + 1)
29+
// } else {
30+
// freqMap.clear()
31+
// l = r + 1
32+
// }
33+
34+
// while (freqMap.size > n) {
35+
// freqMap.set(word[l], freqMap.get(word[l]) - 1)
36+
// if (freqMap.get(word[l]) === 0) {
37+
// freqMap.delete(word[l])
38+
// }
39+
// l++
40+
// }
41+
42+
// result += r - l + 1
43+
// r++
44+
// }
45+
46+
// return result
47+
// }

example/Dayly/3306.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)