1220. Count Vowels Permutation Hard
1/**
2 * [1220] Count Vowels Permutation
3 *
4 * Given an integer n, your task is to count how many strings of length n can be formed under the following rules:
5 *
6 * Each character is a lower case vowel ('a', 'e', 'i', 'o', 'u')
7 * Each vowel 'a' may only be followed by an 'e'.
8 * Each vowel 'e' may only be followed by an 'a' or an 'i'.
9 * Each vowel 'i' may not be followed by another 'i'.
10 * Each vowel 'o' may only be followed by an 'i' or a 'u'.
11 * Each vowel 'u' may only be followed by an 'a'.
12 *
13 * Since the answer may be too large, return it modulo 10^9 + 7.
14 *
15 * Example 1:
16 *
17 * Input: n = 1
18 * Output: 5
19 * Explanation: All possible strings are: "a", "e", "i" , "o" and "u".
20 *
21 * Example 2:
22 *
23 * Input: n = 2
24 * Output: 10
25 * Explanation: All possible strings are: "ae", "ea", "ei", "ia", "ie", "io", "iu", "oi", "ou" and "ua".
26 *
27 * Example 3:
28 *
29 * Input: n = 5
30 * Output: 68
31 *
32 * Constraints:
33 *
34 * 1 <= n <= 2 * 10^4
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/count-vowels-permutation/
40// discuss: https://leetcode.com/problems/count-vowels-permutation/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn count_vowel_permutation(n: i32) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_1220() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.