FastPrepNumber of Substrings Without Vowels

Number of Substrings Without Vowels

TikTok logoTikTokEasyOA
Learn

Problem statement

Given a string (length 1 to 1000), return the number of substrings which don't have any vowels. Circular substrings are valid.

Function

numberOfSubstringsWithoutVowels(s: String) → int

Examples

Example 1

s = "abc"return = 3

All possible substrings are: a, b, c, ab, bc, ca, abc, bca, cab substrings that do not have vowels are: b, c, bc so we return 3

Constraints

  • 🙋‍♀️

More TikTok problems

See TikTok hiring insights
public int numberOfSubstringsWithoutVowels(String s) {
  // write your code here
}
s"abc"
expected3
Checking account…