<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>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> 5
<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>
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 15
<strong>Explanation:</strong> The 15 sorted strings that consist of vowels only are
[&quot;aa&quot;,&quot;ae&quot;,&quot;ai&quot;,&quot;ao&quot;,&quot;au&quot;,&quot;ee&quot;,&quot;ei&quot;,&quot;eo&quot;,&quot;eu&quot;,&quot;ii&quot;,&quot;io&quot;,&quot;iu&quot;,&quot;oo&quot;,&quot;ou&quot;,&quot;uu&quot;].
Note that &quot;ea&quot; is not a valid string since &#39;e&#39; comes after &#39;a&#39; in the alphabet.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> n = 33
<strong>Output:</strong> 66045
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 50</code>&nbsp;</li>
</ul>

class Solution {
public:

        int total=0;

        int countstring (int n ,vector<char>&alpha,char lastused,int len,vector<vector<int>>&dp){
                if(len<=0){
                    return 1;
                }
                if(dp[len][lastused]!=-1) return dp[len][lastused];
                int take=0;

                for(int i=0;i<5;i++){
                    if(alpha[i]>=lastused or lastused=='#'){
                        take+=countstring(n,alpha,alpha[i],len-1,dp);
                    }
                }
               
               return dp[len][lastused]=take;
        }

    int countVowelStrings(int n) {
        vector<vector<int>>dp(n+1,vector<int>(126,-1));
        vector<char>alpha={'a','e','i','o','u'};
        return countstring(n,alpha,'#',n,dp);
        // for(int i=0;i<5;i++){
        //     dp[0][alpha[i]]=1;
        // }
        // dp[0]['#']=1;
        // char lastused='#';
        // int ans=0;
        // for(int i=1;i<n;i++){
        //     int take=0;
            
        //    for(int j=0;j<5;j++){
        //             if(alpha[j]>=lastused or lastused=='#'){
        //                 take+=dp[i-1][lastused];
        //                 lastused=alpha[j];
        //             }
        //         }
        //         dp[i][lastused]=take;
        //         ans+=take;
        // }
        // return ans;
    }
};
8500