java.lang.Object
g1601_1700.s1641_count_sorted_vowel_strings.Solution

public class Solution extends Object
1641 - Count Sorted Vowel Strings.<p>Medium</p> <p>Given an integer <code>n</code>, return <em>the number of strings of length</em> <code>n</code> <em>that consist only of vowels (</em><code>a</code><em>,</em> <code>e</code><em>,</em> <code>i</code><em>,</em> <code>o</code><em>,</em> <code>u</code><em>) and are <strong>lexicographically sorted</strong>.</em></p> <p>A string <code>s</code> is <strong>lexicographically sorted</strong> if for all valid <code>i</code>, <code>s[i]</code> is the same as or comes before <code>s[i+1]</code> in the alphabet.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 1</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> The 5 sorted strings that consist of vowels only are <code>[&quot;a&quot;,&quot;e&quot;,&quot;i&quot;,&quot;o&quot;,&quot;u&quot;].</code></p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 2</p> <p><strong>Output:</strong> 15</p> <p><strong>Explanation:</strong> The 15 sorted strings that consist of vowels only are</p> <p>[&ldquo;aa&rdquo;,&ldquo;ae&rdquo;,&ldquo;ai&rdquo;,&ldquo;ao&rdquo;,&ldquo;au&rdquo;,&ldquo;ee&rdquo;,&ldquo;ei&rdquo;,&ldquo;eo&rdquo;,&ldquo;eu&rdquo;,&ldquo;ii&rdquo;,&ldquo;io&rdquo;,&ldquo;iu&rdquo;,&ldquo;oo&rdquo;,&ldquo;ou&rdquo;,&ldquo;uu&rdquo;].</p> <p>Note that &ldquo;ea&rdquo; is not a valid string since &lsquo;e&rsquo; comes after &lsquo;a&rsquo; in the alphabet.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> n = 33</p> <p><strong>Output:</strong> 66045</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 50</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • countVowelStrings

      public int countVowelStrings(int n)