Skip to content

Practice Count Beautiful Substrings I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2947
LeetCode Problem

Count Beautiful Substrings I

Problem Statement

Count nonempty contiguous substrings of s having equal numbers of vowels and consonants and having the product of those two counts divisible by k. Vowels are a,e,i,o,u; all other English letters are consonants.

Source: Count Beautiful Substrings I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "baeyh", k = 2
Output
2

# Example 2

Input
s = "abba", k = 1
Output
3

# Example 3

Input
s = "bcdf", k = 1
Output
0

Constraints

1 <= s.length <= 1000
1 <= k <= 1000
s consists of only English lowercase letters.

Related LeetCode Problems

Practice more problems similar to Count Beautiful Substrings I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.