Count Vowel Permutations
Problem statement
Return the number of length-n strings made only from a, e, i, o, and u that follow these rules:
amay be followed only bye.emay be followed only byaori.imay be followed bya,e,o, oru.omay be followed only byioru.umay be followed only bya.
Return the count modulo 1,000,000,007.
Function
countVowelPermutations(n: int) → intExamples
Example 1
n = 1return = 5Every single vowel is valid.
Example 2
n = 2return = 10The valid transitions are ae, ea, ei, ia, ie, io, iu, oi, ou, ua.
Example 3
n = 5return = 68Dynamic programming counts valid strings ending in each vowel after five positions.
Constraints
1 <= n <= 20000