3305. Count of Substrings Containing Every Vowel and K Consonants I Medium…
- User
- Count of Substrings Containing Every Vowel and K Consonants I Medium TopicsCompanies Hint 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: 1 Explanation: The only substring with every vowel and zero consonants is word[0..4], which is "aeiou". Example 3: Input: word = "ieaouqqieaouqq", k = 1 Output: 3 Explanation: The substrings with every vowel and one consonant are: word[0..5], which is "ieaouq". word[6..11], which is "qieaou". word[7..12], which is "ieaouq".
Constraints: 5 <= word.length <= 250 word consists only of lowercase English letters. 0 <= k <= word.length - 5
Q- explain this problem using your own words.
You are a string called “word” and an integer “k” Our task is to search numbers all the subarray that satisify these constrain oky —> this subArray to contain vowels {“a” ,”e”,”i”,”o”,”u”} , at least one time —> an contain k constants char oky
Q-what is the input&ouput ? Input : word : string , k:int Output : int
Q- do you have any hints or notes to do ?
Given that any valid subarray need to have all vowels at least once Which are 5 in total And k number of constant char I think the window size will be 5+k Why this is important ? Because it reduce the problem space from dynamic slide windows to static one ?
Q- piss : i think the best solution here is to use slide window but the actual implementation and pattern need further search
Q- can you go through an example ? Input: word = "aeioukt", k = 0
Oky this example “aeioukt” and k=0
Leveraging the previous observation of 5+k = 5 this our case we can see that All the possible sub_array here are “Aeiou” —> only this verify all the constrain oky “Eiouk” “Ioukt
Q- before comincieg to more details implementation use chain of throughs to test all my hypthoerices using chain of through and math proff to test and validate them all
Q- then conclude with the right solution oky
- Assistant