Count Sorted Vowel Strings - Problem
Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.
A string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.
Input & Output
Example 1 — Basic Case
$
Input:
n = 1
›
Output:
5
💡 Note:
All single vowel strings are valid: 'a', 'e', 'i', 'o', 'u' are all lexicographically sorted by themselves
Example 2 — Small Length
$
Input:
n = 2
›
Output:
15
💡 Note:
Valid strings include 'aa', 'ae', 'ai', 'ao', 'au', 'ee', 'ei', 'eo', 'eu', 'ii', 'io', 'iu', 'oo', 'ou', 'uu'. Invalid would be 'ea', 'ia', etc.
Example 3 — Larger Case
$
Input:
n = 33
›
Output:
66045
💡 Note:
For n=33, using the mathematical formula C(33+4, 4) = C(37, 4) = 66045 valid sorted vowel strings
Constraints
- 1 ≤ n ≤ 50
Visualization
Tap to expand
Understanding the Visualization
1
Input
Given length n, need to count sorted vowel strings
2
Process
Find combinations where each char ≤ next char
3
Output
Return count of valid strings
Key Takeaway
🎯 Key Insight: This is equivalent to choosing vowels with repetition - a classic combinatorics problem with O(1) solution
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code