Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save priyankvex/2d8710dd3251716a1291c2b25ebd4540 to your computer and use it in GitHub Desktop.
Save priyankvex/2d8710dd3251716a1291c2b25ebd4540 to your computer and use it in GitHub Desktop.
Number of substrings starting with a vowel
class Solution(object):
def solve(self, s):
vowels = {"a", "e", "i", "o", "u", "A", "E", "I", "O", "U"}
ans = 0
for i, c in enumerate(s):
if c in vowels:
ans += len(s) - i
return ans
if __name__ == "__main__":
a = "ABEC"
ans = Solution().solve(a)
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment