pyassistant

Count substrings with equal vowels and consonants

Given a non-empty string s consisting only of lowercase English letters, return the number of substrings in which the number of vowels equals the number of consonants. Vowels are the letters 'a', 'e', 'i', 'o', 'u'. A substring is a contiguous sequence of characters within s. The answer should count all substrings (including overlapping ones) that have equal counts of vowels and consonants.

Example:

Input:
('abae',)
Output:
2

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.