[C++] Simplest Approach, Pattern recognizing and Efficient O(n). ✅
Question:\n\nGiven an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.\n\nA str
**Question:**\n```\nGiven an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.\n\nA string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.\n```\n* Before jumping to answering the question, lets understand **lexicographic order**. What it is?\n* The term **Lexicographical order** is a mathematical term known by names: lexical order, lexicographic(al) product, alphabetical order, or **dictionary order**. \n* *You can read more at:[Javatpoint](https://www.javatpoint.com/lexicographical-order-java)*\n* Question is a simple question of permutation and combinations, given there is a length of string given "n" we have to find ho many combinations are possible **only of length n** and by using **only vowels** i.e. a,e,i,o,u. Let\'s understand the same with the given test case.\n\n**Example Test Case:**\n```\nInput: n = 1\nOutput: 5\nExplanation: The 5 sorted strings that consist of vowels only are ["a","e","i","o","u"].\n```\n\n* Now, we need to understand a simple pattern which is being followed in the question:\n```\n\t      a  e  i  o  u\n    n=1   1  1  1  1  1  /a, e, i, o, u\n    n=2   5  4  3  2  1  /a-> aa,ae,ai,ao,au | e-> ee,ei,eo,eu | i-> ii,io,iu | o-> oo,ou | u-> uu\n```\n**Solution:**\n* We areu using 5 variables that are given in the question a,e,i,o,u.\n* Here we are adding previous value with the current next element in serial order of of a-e-i-o-u.\n* To understand this go to above example where **n=2**, the while loop will run one time and there will be only **one element** which start with **\'u\'**. For every other element you can see it is **previous+next count.**\n* We will return the function by adding every element(variable) at the end.\n*  Time complexity: O(n).\n\n**Solution:**\n```\nclass Solution {\npublic:\n    int countVowelStrings(int n) {\n        int a=1,e=1,i=1,o=1,u=1;\n        while(--n)\n        {\n            o+=u;\n            i+=o;\n            e+=i;\n            a+=e;\n        }\n        return a+e+i+o+u;\n    }\n};\n```\n**I hope you guys resolved your doubt/query or have learned a new thing, if you really liked the approach / solution / content / explanation don\'t forget to upvote!!. Cheers!!**
['C', 'C++']