mediumHash TableSliding WindowString 0 views

Count of Substrings Containing Every Vowel and K Consonants I

You are given a string word and a non-negative integer k.

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.

Count of Substrings Containing Every Vowel and K Consonants I diagram

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:

Constraints

  • 5 <= word.length <= 250
  • word consists only of lowercase English letters.
  • 0 <= k <= word.length - 5

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.