Java || From recursion to memoization to tabulation || easy and explained
Recursion -->\n[ Time-Complexity = exponential, Space-Complexity = O(n) ]\n\nclass Solution {\n   int count =0;\n    public int countVowelStrings(int n) {\n    
Recursion -->\n[ Time-Complexity = exponential, Space-Complexity = O(n) ]\n```\nclass Solution {\n   int count =0;\n    public int countVowelStrings(int n) {\n        String[] s= new String[]{"a","e","i","o","u"};\n        \n       int ans = solve(0,n,s);\n        return ans;\n    }\n    public int solve(int ind , int n ,String[] s){\n        if(n==0){\n            return 1;\n        }\n        if(ind>=s.length)return 0;\n        \n        int pick = solve(ind,n-1,s);\n        int notPick = solve(ind+1,n,s);\n        \n        return (pick+notPick);\n    }\n    \n}\n```\n\nMemoization-->>\n[ Time-Complexity = O(4*N), Space-Complexity = O(5*n)+O(N) ]\n```\nclass Solution {\n    int count = 0;\n\n    public int countVowelStrings(int n) {\n        String[] s = new String[] { "a", "e", "i", "o", "u" };\n        int[][] dp = new int[5][n + 1];\n        for (int[] x : dp) {\n            Arrays.fill(x, -1);\n        }\n        int ans = solve(0, n, s,dp);\n        return ans;\n    }\n\n    public int solve(int ind, int n, String[] s,int[][] dp) {\n        if (n == 0) {\n            return 1;\n        }\n        if (ind >= s.length) return 0;\n        if(dp[ind][n]!=-1) return dp[ind][n];\n\n        int pick = solve(ind, n - 1, s,dp);\n        int notPick = solve(ind + 1, n, s,dp);\n\n        return dp[ind][n] = (pick + notPick);\n    }\n}\n```\n\nTabulation-->>\n[ Time-Complexity = O(4*N), Space-Complexity =O(N) ]\n```\nclass Solution {\n    public int countVowelStrings(int n) {\n        String[] s = new String[] { "a", "e", "i", "o", "u" };\n        int[][] dp = new int[5][n + 1];\n        for(int i=0;i<s.length;i++)\n            dp[i][0] = 1;\n        for(int i =4;i>=0;i--){\n            for(int j=1;j<=n;j++){\n                int pick = dp[i][j-1];\n                int notPick = 0;\n              if(i<4) notPick = dp[i+1][j];\n                dp[i][j] = (pick+notPick);\n            }\n        }\n        return dp[0][n];\n    }\n}\n```\nplease upvote if helped.
['Dynamic Programming', 'Memoization', 'Java']