Simple Solution || Recursion || Memoization || Tabular Dynamic Programming
Recursion || Memoization || Tabular Dynamic Programming\n\nRecursion:\n\nThought Process:\n1.  Pick an element in repeated times.\n2. Don\'t pick the element.\n
### Recursion || Memoization || Tabular Dynamic Programming\n\n**Recursion:**\n\n*Thought Process:*\n1.  Pick an element in repeated times.\n2. Don\'t pick the element.\n(Same thought of `unbounded knapsack` or `combination sum I` problem)\n\n> **Void Recursion:**\n\n```\nclass Solution {\npublic:\n    \n    void calculate(vector<char>& v,int n,int index,int& ans){\n        if(n == 0){\n\t\t/* when the string length becomes 0, then we have found the lexicographically \n\t\tsorted string ,increment ans by 1.*/\n\t\t\tans++;\n            return;\n        }\n        if(index >= v.size()) return;\n        //pick - after picking element, string length reduce by 1\n        calculate(v,n-1,index,ans);\n        // not pick - if i didn\'t pick the element, string lenght should be same\n        calculate(v,n,index+1,ans);\n    }\n    \n    int countVowelStrings(int n) {\n        vector<char> v{\'a\',\'e\',\'i\',\'o\',\'u\'};\n        int index = 0; // starting picking elements from index 0\n        int ans = 0;\n        calculate(v,n,index,ans);\n        return ans;\n    }\n};\n```\n\n> **Value Returning Recustion:**\n\n```\nclass Solution {\npublic:\n    \n    int calculate(vector<char>& v,int n,int index){\n        if(n == 0){\n            return 1;\n        }\n        if(index >= v.size()) return 0;\n        //pick\n        int x = calculate(v,n-1,index);\n        // not pick\n        int y = calculate(v,n,index+1);\n        return x+y;\n    }\n    \n    int countVowelStrings(int n) {\n        vector<char> v{\'a\',\'e\',\'i\',\'o\',\'u\'};\n        int index = 0;\n        int ans = 0;\n        ans = calculate(v,n,index);\n        return ans;\n    }\n};\n```\n\n> **Memoization:**\n\n- Now as we found the returning value Recursion functionn, now we will easily memoize it\n- See, which parameters are changing in our recursion function\n\t1. n\n\t2. index\n- So, our memoization vector is 2d vector.\n\n```\nclass Solution {\npublic:\n    \n    int calculate(vector<char>& v,int n,int index,vector<vector<int>>& memo){\n        if(n == 0){\n            return 1;\n        }\n        if(memo[n][index] != -1) return memo[n][index];\n        if(index >= v.size()) return 0;\n        //pick\n        int x = calculate(v,n-1,index,ans,memo);\n        // not pick\n        int y = calculate(v,n,index+1,ans,memo);\n        return memo[n][index] = x+y;\n    }\n    \n    int countVowelStrings(int n) {\n        vector<char> v{\'a\',\'e\',\'i\',\'o\',\'u\'};\n        int index = 0;\n        int ans = 0;\n        vector<vector<int>> memo(n+1,vector<int>(6,-1)); // 5 vowels\n        ans = calculate(v,n,index,memo);\n        return ans;\n    }\n};\n```\n\n> **Tabulation**\n\n```\nclass Solution {\npublic:\n    \n    int countVowelStrings(int n) {\n        vector<char> v{\'a\',\'e\',\'i\',\'o\',\'u\'};\n        int index = 0;\n        int ans = 0;\n        vector<vector<int>> dp(n+1,vector<int>(5,0)); // 5 vowels\n        \n        /* base case fill\n\t\t\t if n == 1 , \n\t\t\t then a,e,i,o,u :  number if length 1 string starting with a,e,i,o,u is 1\n        */\n\t\tfor(int i = 1; i < 5 ; i++){\n            dp[1][i] = 1;\n        }\n        \n        /* for the case of u, if n = 1,2,3,4,... \n\t\t\tthe number of strings generated by u is: u,uu,uuu,uuuu,... \n\t\t\ti.e., 1 one string respectively.\n        */\n\t\t\n\t\t/*\n         base case fill , if char = u\n\t\t\t- at index 4 char is u in v vector\n        */\n\t\t\n\t\tfor(int N = 1; N < n+1 ; N++){\n            dp[N][4] = 1;\n        }\n        \n        \n        // n->i and index -> j replaceing in recursion memo\n        for(int i = 1 ; i < n+1 ; i++){\n\t\t// in increasing order of n.\n            for(int j = 3 ; j >=0 ; j--){ \n\t\t\t// in decreasing order of vowels as we dp[i][j] depends on dp[i][j+1];\n                dp[i][j] = dp[i-1][j] + dp[i][j+1];\n            }\n        }\n        return accumulate(dp[n].begin(),dp[n].end(),0); // sum of the last vector dp[n] is our ans.\n    }\n};\n```
['Dynamic Programming', 'Backtracking', 'Recursion', 'Memoization']