Recursion and memoization in python
for 1 ; a,e,i,o,u                 value = 5\nfor 2: \naa, ae, ai, ao, au\n\t\t\t   ee, ei, eo, eu\n\t\t\t\t\t ii,  io,  iu\n\t\t\t\t\t\t oo, ou\n\t\t\t\t\t\t\t 
for 1 ; a,e,i,o,u                 value = 5\nfor 2: \naa, ae, ai, ao, au\n\t\t\t   ee, ei, eo, eu\n\t\t\t\t\t ii,  io,  iu\n\t\t\t\t\t\t oo, ou\n\t\t\t\t\t\t\t   uu      \n\t\t\t\t\t\t\t   value = 15\nfor 3: we can add a to all the strings in previous case so 15 will already be there.value will be  (n = 2, w = 5) = 15\nlets look at the remaining cases.\n\tnow we need to find values with 4 vowels {e,i,o,u} and need to have 3 lettered strings. i.e (n = 3, vow = 4)\n```\nwe can say f(n = 3, vow = 5) = f(n = 2, vow = 5) # for a case\n\t\t\t\t\t+ f(n = 3, vow = 4) #after removal of a left with vow = 4\n```\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\n\tso we are getting a recursion: \n\t recur(n,w) = recur(n-1, w) //here in the previous case, (2,5)\n\t\t\t\t\t\t + recur(n,w-1) // after using a we are left with {e,i,o,u} so w-1 for that\n```\ndef countVowelStrings(self, n: int) -> int:\n        def count(n,vow):\n            if vow == 0: return 0\n            if n == 0: return 1\n            return count(n,vow-1)+count(n-1,vow)\n        return count(n,5)\n```\nFor memoization: \njust use a table of size (n+1) * (w+1) and fill it with -1. \nassign values to table and use it whenever its not -1( which means already assigned)\n```\nclass Solution:\n    def countVowelStrings(self, n: int) -> int:\n        def count(n,vow):\n            if vow == 0: \n                mem[n][vow] =  0\n                return mem[n][vow]\n            if n == 0: \n                mem[n][vow] = 1\n                return mem[n][vow]\n            if mem[n][vow]!=-1:\n                return mem[n][vow]\n            mem[n][vow] = count(n,vow-1)+count(n-1,vow)\n            return mem[n][vow]\n        mem = [[-1]*6 for i in range(n+1)]\n        return count(n,5)\n```
['Recursion', 'Memoization', 'Python', 'Python3']