-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy path1220-count-vowels-permutation.py
30 lines (24 loc) · 1.27 KB
/
1220-count-vowels-permutation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Solution:
def countVowelPermutation(self, n: int) -> int:
a_vowel_permutation_count = [1] * n
e_vowel_permutation_count = [1] * n
i_vowel_permutation_count = [1] * n
o_vowel_permutation_count = [1] * n
u_vowel_permutation_count = [1] * n
MOD = 10 ** 9 + 7
for i in range(1, n):
a_vowel_permutation_count[i] = (
e_vowel_permutation_count[i - 1] + i_vowel_permutation_count[i - 1] + u_vowel_permutation_count[i - 1]) % MOD
e_vowel_permutation_count[i] = (
a_vowel_permutation_count[i - 1] + i_vowel_permutation_count[i - 1]) % MOD
i_vowel_permutation_count[i] = (
e_vowel_permutation_count[i - 1] + o_vowel_permutation_count[i - 1]) % MOD
o_vowel_permutation_count[i] = (
i_vowel_permutation_count[i - 1]) % MOD
u_vowel_permutation_count[i] = (
i_vowel_permutation_count[i - 1] + o_vowel_permutation_count[i - 1]) % MOD
result = 0
result = (a_vowel_permutation_count[n - 1] + e_vowel_permutation_count[n - 1] +
i_vowel_permutation_count[n - 1] + o_vowel_permutation_count[n - 1] +
u_vowel_permutation_count[n - 1]) % MOD
return result