1641. Count Sorted Vowel Strings Medium

@problem@discussion
#Dynamic Programming



1/**
2 * [1641] Count Sorted Vowel Strings
3 *
4 * 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.
5 * 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.
6 *  
7 * Example 1:
8 * 
9 * Input: n = 1
10 * Output: 5
11 * Explanation: The 5 sorted strings that consist of vowels only are ["a","e","i","o","u"].
12 * 
13 * Example 2:
14 * 
15 * Input: n = 2
16 * Output: 15
17 * Explanation: The 15 sorted strings that consist of vowels only are
18 * ["aa","ae","ai","ao","au","ee","ei","eo","eu","ii","io","iu","oo","ou","uu"].
19 * Note that "ea" is not a valid string since 'e' comes after 'a' in the alphabet.
20 * 
21 * Example 3:
22 * 
23 * Input: n = 33
24 * Output: 66045
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= n <= 50 
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/count-sorted-vowel-strings/
35// discuss: https://leetcode.com/problems/count-sorted-vowel-strings/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn count_vowel_strings(n: i32) -> i32 {
41        0
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_1641() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.