Skip to content

Commit

Permalink
leetcode count vowel strings in ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Feb 23, 2024
1 parent 1c37ce8 commit 71e441f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions leetcode/algorithms/medium/count_vowel_strings_in_ranges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import List


class Solution:
def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]:
ws = [w[0] in "aeiou" and w[-1] in "aeiou" for w in words]
ls, c = [], 0
for w in ws:
if w:
c += 1
ls.append(c)
return [ls[j] - (ls[i - 1] if i > 0 else 0) for i, j in queries]

0 comments on commit 71e441f

Please sign in to comment.