Skip to content

Instantly share code, notes, and snippets.

@Ifihan
Created March 10, 2025 22:51
Show Gist options
  • Save Ifihan/831245bfd6c6cd80d3fb56fecc102baf to your computer and use it in GitHub Desktop.
Save Ifihan/831245bfd6c6cd80d3fb56fecc102baf to your computer and use it in GitHub Desktop.
Count of Substrings Containing Every Vowel and K Consonants II

Question

Approach

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

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment