We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 87728b6 commit dd6d5b9Copy full SHA for dd6d5b9
scripts/algorithms/C/Count Vowels Permutation/Count Vowels Permutation.rs
@@ -0,0 +1,29 @@
1
+// Runtime: 0 ms (Top 100.0%) | Memory: 2.30 MB (Top 28.0%)
2
+
3
+impl Solution {
4
+ pub fn count_vowel_permutation(n: i32) -> i32 {
5
+ const MOD: i64 = 1e9 as i64 + 7;
6
7
+ let mut a = 1;
8
+ let mut e = 1;
9
+ let mut i = 1;
10
+ let mut o = 1;
11
+ let mut u = 1;
12
13
+ for _ in 1..n {
14
+ let a_next = e;
15
+ let e_next = (a + i) % MOD;
16
+ let i_next = (a + e + o + u) % MOD;
17
+ let o_next = (i + u) % MOD;
18
+ let u_next = a;
19
20
+ a = a_next;
21
+ e = e_next;
22
+ i = i_next;
23
+ o = o_next;
24
+ u = u_next;
25
+ }
26
27
+ ((a + e + i + o + u) % MOD) as i32
28
29
+}
0 commit comments