Skip to content

Commit 8d2a602

Browse files
committed
Jan 2
1 parent 67c2d40 commit 8d2a602

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
VOWELS = {'a', 'e', 'i', 'o', 'u'}
6+
7+
def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]:
8+
p_sums = [0]
9+
curr = 0
10+
for word in words:
11+
if word[0] in self.VOWELS and word[-1] in self.VOWELS:
12+
curr += 1
13+
p_sums.append(curr)
14+
return [p_sums[r + 1] - p_sums[l] for l, r in queries]
15+
16+
17+
def main():
18+
words = ['aba', 'bcb', 'ece', 'aa', 'e']
19+
queries = [[0, 2], [1, 4], [1, 1]]
20+
assert Solution().vowelStrings(words, queries) == [2, 3, 0]
21+
22+
words = ['a', 'e', 'i']
23+
queries = [[0, 2], [0, 1], [2, 2]]
24+
assert Solution().vowelStrings(words, queries) == [3, 2, 1]
25+
26+
27+
if __name__ == '__main__':
28+
main()

2025-01-January-LeetCoding-Challenge/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| Day | Problem | Level | Status |
55
| --- | --- | --- | --- |
66
| January 1 | [1422. Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string/) | Easy | Solved |
7-
| January 2 | []() | | |
7+
| January 2 | [2559. Count Vowel Strings in Ranges](https://leetcode.com/problems/count-vowel-strings-in-ranges/) | Medium | Solved |
88
| January 3 | []() | | |
99
| January 4 | []() | | |
1010
| January 5 | []() | | |
@@ -40,5 +40,5 @@
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
4242
| Easy | 1 | 1 | 0 |
43-
| Medium | 0 | 0 | 0 |
43+
| Medium | 1 | 1 | 0 |
4444
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)