FastPrepCount Vowel Substrings of a String

Count Vowel Substrings of a String

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN
Learn

Problem statement

A vowel substring is a non-empty contiguous substring that contains only the lowercase vowels a, e, i, o, and u, and contains all five vowels at least once.

Given a lowercase English string word, return the number of vowel substrings.

Function

countVowelSubstrings(word: String) → long

Examples

Example 1

word = "aeiouu"return = 2

The valid substrings are aeiou and aeiouu.

Example 2

word = "unicornarihan"return = 0

No all-vowel substring contains every vowel.

Example 3

word = "cuaieuouac"return = 7

Seven contiguous substrings contain only vowels and include all five vowel types.

Constraints

  • 1 <= word.length() <= 100000.
  • word contains only lowercase English letters.
  • The answer fits in a signed 64-bit integer.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public long countVowelSubstrings(String word) {
    // Write your code here.
}
word"aeiouu"
expected2
Checking account…