N^2 with Pruning
N^2 solutions sometimes can be pruned to a point that they actually work well. This is an example: we can solve in N^2 by going thru all the substrings, but if we get to a point where the count of consonants is less than zero, we skip the inner loop, cutting down the search time considerably. Code is down below, cheers, ACC. Count of Substrings Containing Every Vowel and K Consonants I - LeetCode 3305. Count of Substrings Containing Every Vowel and K Consonants I Medium 34 4 Add to List Share You are given a string word and a non-negative integer k . Return the total number of substrings of word that contain every vowel ( 'a' , 'e' , 'i' , 'o' , and 'u' ) at least once and exactly k consonants. Example 1: Input: word = "aeioqq", k = 1 Output: 0 Explanation: There is no substring with every vowel. Example 2: Input: word = "aeiou", k = 0 Output: ...