Class Solution
java.lang.Object
g1201_1300.s1220_count_vowels_permutation.Solution
1220 - Count Vowels Permutation.<p>Hard</p>
<p>Given an integer <code>n</code>, your task is to count how many strings of length <code>n</code> can be formed under the following rules:</p>
<ul>
<li>Each character is a lower case vowel (<code>'a'</code>, <code>'e'</code>, <code>'i'</code>, <code>'o'</code>, <code>'u'</code>)</li>
<li>Each vowel <code>'a'</code> may only be followed by an <code>'e'</code>.</li>
<li>Each vowel <code>'e'</code> may only be followed by an <code>'a'</code> or an <code>'i'</code>.</li>
<li>Each vowel <code>'i'</code> <strong>may not</strong> be followed by another <code>'i'</code>.</li>
<li>Each vowel <code>'o'</code> may only be followed by an <code>'i'</code> or a <code>'u'</code>.</li>
<li>Each vowel <code>'u'</code> may only be followed by an <code>'a'.</code></li>
</ul>
<p>Since the answer may be too large, return it modulo <code>10^9 + 7.</code></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 1</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> All possible strings are: “a”, “e”, “i” , “o” and “u”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 2</p>
<p><strong>Output:</strong> 10</p>
<p><strong>Explanation:</strong> All possible strings are: “ae”, “ea”, “ei”, “ia”, “ie”, “io”, “iu”, “oi”, “ou” and “ua”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> n = 5</p>
<p><strong>Output:</strong> 68</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 2 * 10^4</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countVowelPermutation
public int countVowelPermutation(int n)
-