✅ Python 4 approaches (DP, Maths)
DP Tabulation\n\nclass Solution:\n    def countVowelStrings(self, n: int) -> int:        \n        dp = [[0] * 6 for _ in range(n+1)]\n        for i in range(1,
1. ##### DP Tabulation\n```\nclass Solution:\n    def countVowelStrings(self, n: int) -> int:        \n        dp = [[0] * 6 for _ in range(n+1)]\n        for i in range(1, 6):\n            dp[1][i] = i\n        \n        for i in range(2, n+1):\n            dp[i][1]=1\n            for j in range(2, 6):\n                dp[i][j] = dp[i][j-1] + dp[i-1][j]\n        \n        return dp[n][5]\n```\n**Time = O(n)**\n**Space = O(n)**\n\n---\n2. ##### O(1) Space\n```\nclass Solution:\n    def countVowelStrings(self, n: int) -> int:        \n        dp = [1] * 5\n        \n        for i in range(2, n+1):\n            for j in range(4, -1, -1):\n                dp[j] += sum(dp[:j])            \n        \n        return sum(dp)\n```\n\nAlternative solution shared by [@koacosmos](https://leetcode.com/koacosmos/)\n\n```\nclass Solution:\n    def countVowelStrings(self, k: int) -> int:        \n        dp = [1] * 5\n                                \n        for _ in range(1, k):\n            for i in range(1, 5):                    \n                dp[i] = dp[i] + dp[i-1]\n        \n        return sum(dp)\n```\n**Time = O(n)**\n**Space = O(1)**\n\n---\n\n3. ##### Mathematical equation using [Combinations with repetition](https://en.wikipedia.org/wiki/Combination#Number_of_combinations_with_repetition)\n```\nclass Solution:\n    def countVowelStrings(self, n: int) -> int:        \n        return (n + 4) * (n + 3) * (n + 2) * (n + 1) // 24;\n```\n\n---\nSolution shared by [@nithinmanne1](https://leetcode.com/nithinmanne1/) using Python internal library.\n```\nclass Solution:\n    def countVowelStrings(self, n: int) -> int:        \n        return math.comb(n + 4, 4)\n```\n\n**Time = O(1)\nSpace = O(1)**\n\n----\n\nOther contributers of this post:\n1. [@nithinmanne1](https://leetcode.com/nithinmanne1/)\n2. [@koacosmos](https://leetcode.com/koacosmos/)\n\n---\n\n***Please upvote if you find it useful***
['Python', 'Python3']