Tap here to switch tabs
Problem
Submissions

Problem: Count Beautiful Substrings II

Try to solve the Count Beautiful Substrings II problem.

Statement

You are given a string s and a positive integer k.

Let vowels and consonants denote the number of vowels and consonants in a substring, respectively.

A substring is considered beautiful if:

  • vowels == consonants

  • (vowels * consonants) % k =0= 0

Return the total number of nonempty beautiful substrings in s.

The English vowels are 'a', 'e', 'i', 'o', and 'u'. All other lowercase English letters are consonants.

A substring is a contiguous sequence of characters within a string.

Constraints:

  • 1≤1 \leq s.length ≤5×104\leq 5 \times 10^4

  • 1≤1 \leq k ≤1000\leq 1000

  • s consists of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Beautiful Substrings II

Try to solve the Count Beautiful Substrings II problem.

Statement

You are given a string s and a positive integer k.

Let vowels and consonants denote the number of vowels and consonants in a substring, respectively.

A substring is considered beautiful if:

  • vowels == consonants

  • (vowels * consonants) % k =0= 0

Return the total number of nonempty beautiful substrings in s.

The English vowels are 'a', 'e', 'i', 'o', and 'u'. All other lowercase English letters are consonants.

A substring is a contiguous sequence of characters within a string.

Constraints:

  • 1≤1 \leq s.length ≤5×104\leq 5 \times 10^4

  • 1≤1 \leq k ≤1000\leq 1000

  • s consists of only lowercase English letters.