C++ Top Down DP and Formula
Top Down DP\nTop down DP was the easiest for me to get started. \n\ncpp\nint dp[51][5] = {};\nint countVowelStrings(int n, int prev = 0) {\n    if (n == 1)\n   
#### Top Down DP\nTop down DP was the easiest for me to get started. \n\n```cpp\nint dp[51][5] = {};\nint countVowelStrings(int n, int prev = 0) {\n    if (n == 1)\n        return 5 - prev;\n    if (dp[n][prev] == 0)\n        for (int i = prev; i < 5; ++i)\n            dp[n][prev] += countVowelStrings(n - 1, i);\n    return dp[n][prev]\n```\n\n#### Formula\nWhile converting the solution above to bottom-up DP, I realized that there is a pattern we can describe with a simple formula.\n1) 1 + (1 + 2) | + 1\n2) 1 + (1 + 2) + (1 + 2 + 3) | + 1 + (1 + 2) | + 1\n3) 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3 + 4) | + 1 + (1 + 2) + (1 + 2 + 3) | + 1 + (1 + 2) | + 1\n4) 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3 + 4) + (1 + 2 + 3 + 4 + 5)| + (#3)\n- or\n4) 5 * (5 + 1) / 2 + #3\n5) 6 * (6 + 1)  /2 + #4\n\n```cpp\nint countVowelStrings(int n) {\n    int res = 0, sum = 0;\n    for (int i = 1; i <= n + 1; ++i) {\n        sum += i * (i + 1) / 2;\n        res += sum;\n    }\n    return res;\n}\n```
[]