I use a sliding window approach that dynamically expands and shrinks. Then I track vowel occurrences and ensure all 5 vowels appear at least once.
After that, I count consonants, ensuring exactly k consonants exist in the substring. When conditions are met, I count all valid substrings that start from left
to right
. This failed for around 22 testcases. I tried other methods but didn't get a solution so I visited the editorial
