Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
โK
Get Premium
Leetcode 2949. Count Beautiful Substrings II
Count the non-empty substrings where vowels == consonants and their product is divisible by k; since equality implies length 2t with t vowels, the problem reduces to counting substrings of length 2t that contain exactly t vowels for every t with t^2 % k == 0. Efficient solutions combine enumerating valid t (up to n/2) with prefix sums or sliding-window counting to handle strings up to 5ยท10^4.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.