fork download
  1. def hasVowel(strArr, queries):
  2. vowels = {'a', 'e', 'i', 'o', 'u'}
  3.  
  4. def is_vowel_string(s):
  5. return len(s) > 0 and s[0] in vowels and s[-1] in vowels
  6.  
  7. if not strArr or not queries:
  8. return []
  9.  
  10. vowel_flags = [is_vowel_string(s) for s in strArr]
  11. results = []
  12.  
  13. for query in queries:
  14. try:
  15. l, r = map(int, query.split('-'))
  16. if l < 1 or r > len(strArr) or l > r:
  17. results.append(0)
  18. else:
  19. results.append(sum(vowel_flags[l-1:r]))
  20. except ValueError:
  21. results.append(0)
  22.  
  23. return results
Success #stdin #stdout 0.04s 9660KB
stdin
aab, a, bcd, awe, bbbbbu
2-3, 4-5
stdout
Standard output is empty