Created
August 26, 2019 15:30
-
-
Save priyankvex/2d8710dd3251716a1291c2b25ebd4540 to your computer and use it in GitHub Desktop.
Number of substrings starting with a vowel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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