Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd6ed40

Browse files
committed
Add solution #2586
1 parent 1c8707a commit dd6ed40

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@
19281928
2582|[Pass the Pillow](./solutions/2582-pass-the-pillow.js)|Easy|
19291929
2583|[Kth Largest Sum in a Binary Tree](./solutions/2583-kth-largest-sum-in-a-binary-tree.js)|Medium|
19301930
2585|[Number of Ways to Earn Points](./solutions/2585-number-of-ways-to-earn-points.js)|Hard|
1931+
2586|[Count the Number of Vowel Strings in Range](./solutions/2586-count-the-number-of-vowel-strings-in-range.js)|Easy|
19311932
2594|[Minimum Time to Repair Cars](./solutions/2594-minimum-time-to-repair-cars.js)|Medium|
19321933
2615|[Sum of Distances](./solutions/2615-sum-of-distances.js)|Medium|
19331934
2618|[Check if Object Instance of Class](./solutions/2618-check-if-object-instance-of-class.js)|Medium|
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* 2586. Count the Number of Vowel Strings in Range
3+
* https://leetcode.com/problems/count-the-number-of-vowel-strings-in-range/
4+
* Difficulty: Easy
5+
*
6+
* You are given a 0-indexed array of string words and two integers left and right.
7+
*
8+
* A string is called a vowel string if it starts with a vowel character and ends with
9+
* a vowel character where vowel characters are 'a', 'e', 'i', 'o', and 'u'.
10+
*
11+
* Return the number of vowel strings words[i] where i belongs to the inclusive range [left, right].
12+
*/
13+
14+
/**
15+
* @param {string[]} words
16+
* @param {number} left
17+
* @param {number} right
18+
* @return {number}
19+
*/
20+
var vowelStrings = function(words, left, right) {
21+
const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
22+
let result = 0;
23+
24+
for (let i = left; i <= right; i++) {
25+
const word = words[i];
26+
if (vowels.has(word[0]) && vowels.has(word[word.length - 1])) {
27+
result++;
28+
}
29+
}
30+
31+
return result;
32+
};

0 commit comments

Comments
 (0)