C++ | Faster than 100% | DP and MATH Approach
The problem can be solved with dynamic programming approach or from a direct math formula. Here I have solved using DP approach.\n dp[vowels[index] - 97] at eve
* The problem can be solved with **dynamic programming approach** or from a **direct math formula**. Here I have solved using DP approach.\n* `dp[vowels[index] - 97]` at every value of `i` stores the number of lexicographically sorted strings which start from `vowels[index]` and is of length `i`.\n*  `vowels[index]` can come before all the lexicographically sorted strings of length `i` starting from `vowels[idx]` **(idx > index)** to form new set of lexicographically sorted strings starting from `vowels[index`] having length `i + 1`. This is the logic for building answers.\n* Build upon this answer till `i == n` and in the end accumulate the answers for each vowel.\n\n**Dynamic Programming Approach :**\n```\nclass Solution {\npublic:\n    int countVowelStrings(int n) {\n        \n        string vowels = "aeiou";\n        int ans;\n        \n        vector<int> dp(26, 0);\n        \n        dp[\'a\' - 97] = 1;\n        dp[\'e\' - 97] = 1;\n        dp[\'i\' - 97] = 1;\n        dp[\'o\' - 97] = 1;\n        dp[\'u\' - 97] = 1;\n        \n        \n        \n        for(int i = 2; i <= n ; i++){\n            \n            for(int j = 0; j < 5; j++){\n                \n                for(int k = j + 1; k < 5; k++){\n                    \n                    dp[vowels[j] - 97] += dp[vowels[k] - 97];\n                    \n                }                \n                \n            }\n            \n        }\n        \n        ans = accumulate(dp.begin(), dp.end(), 0);\n        \n        return ans;\n        \n    }\n};\n```\n\n**Alternate Math Approach :**\n\n```\nclass Solution {\n    \npublic:\n    int countVowelStrings(int n) {\n        \n        return (n+4)*(n+3)*(n+2)*(n+1) / 24;\n    }\n};\n```
['C']