C++ solution with explanation | Two methods with full explanation
Method 1 - (Using Backtracking)\n\nSolution Idea: \n1. We first create a vector storing all the vowels present in English alphabets.\n2. We the create a functio
***Method 1 - (Using Backtracking)***\n\nSolution Idea: \n1. We first create a vector storing all the vowels present in English alphabets.\n2. We the create a function called *helper* which contains the backtracking algo.\n3. The code has been further commented in each part, for better understanding.\n\n```\nclass Solution {\n    \n    int count = 0;\n    vector<int> word = {\'a\', \'e\', \'i\', \'o\', \'u\'}; //vector containg all the 5 vowels.\n    \n    void helper(string &s, int n) // string s contains the answer string.\n    {\n        if(s.size() == n)\n          count++; // if the size of s reaches n (given in the problem), we increase count value by 1.\n        \n        for(int i=0;i<=4;i++)\n        { // iterating over all the elements of vector word.\n            if(s.size() == 0)\n            { // initially, when answer string s in empty, we directly put the letter from word vector, and later perform backtracking.\n\t\t\t\ts.push_back(word[i]);\n\t\t\t\thelper(s, n);\n\t\t\t\ts.pop_back();\n\t\t\t}\n        \n\t\t\telse if(s.size()<n && s.back()<=word[i])\n\t\t\t{ // else if size of answer string is greater than 0, but not yet equal to n, and also **the last letter of the string s, is less than the current letter**,\n\t\t\t  // we push the current letter in the answer string and do the backtracking as usual.\n\t\t\t\ts.push_back(word[i]);\n\t\t\t\thelper(s, n);\n\t\t\t\ts.pop_back();\n\t\t\t}\n        }\n    }\npublic:\n    int countVowelStrings(int n)\n    {\n        string s ;\n        helper(s, n);\n        return count; // returning count value as answer.\n    }\n};\n```\n**Time Complexity = O(5^n)**. \nFor every letter out of n, we have 5 possibilities.\n****\n***Method 2 - (Mathematical Pattern)***\n\nSolution Idea: \n Basic idea is to observe a patern amongst the relationship between the given value of n, and the output.\n\nSome observations - \n\t1. For n=1, output is 5.\n\t2. For n=2, output is 15. \n\t   By Triangle number formula, putting N=5 in\n\t   [ N*(N+1) ]/ [1* 2], we get 15.   \n\t3. For n=3, output is 35.\n\t  Putting N=5, in \n\t [ N*(N+1)* (N+2) ]/ [ 1* 2* 3 ]\n\t \n\t \nSo, for any value n:\nwe put N=5 in the formula - \n\n![image](https://assets.leetcode.com/users/images/953ab72b-8cd5-4c16-aa4a-a57433a47c1a_1612279954.0210714.png)\n\n\t\nHence we arrive at our needed expression.\t\n```  \nclass Solution {   \npublic:\n    int countVowelStrings(int n)\n    {\n        return (n+1)*(n+2)*(n+3)*(n+4)/24;\n    }\n};\n```\n**Time Complexity = O(1)**.\n****\n\nView more solutions [HERE](https://github.com/noob-hu-yaar/Leetcode/tree/master/nandincpp)\n****
[]