Vowels count - simple math - faster
Hi,\n\nWhen we do some paper work for this we could see that vowel \'a\' will have all the values including \'a\', where as vowel \'e\' will have all the letter
Hi,\n\nWhen we do some paper work for this we could see that vowel \'a\' will have all the values including \'a\', where as vowel \'e\' will have all the letter except \'a\'.. as it is already covered in \'a\'.\n\na -> aa, ae, ai, ao, au\ne -> ee, ei, eo, eu\ni -> ii, io, iu\n0 -> oo, ou\nu -> uu\n\nBecause if we add e with a its again ae, so its already covered while sorting it lexicographically.\nSo we don\'t have to append the lexicographically smaller alphabet with bigger one.\n\nso the basic math for doing the same is ->\n1) Initially all the vowels will be 1\n2) Then each step vowels will go by following figure a = a+e+i+o+u, e = e+i+o+u, i=i+o+u.. etc., \n3) Till we reach the given number repeat the process\n\nKindly upvote if it helps, happy learning\n\n```\n\tint a=1, e=1, i=1, o=1, u=1;\n    public int countVowelStrings(int n) { \n    \tfor(int j=1; j<n; j++){\n        \tincrement();\n        }\n    \treturn a+e+i+o+u;\n    }\n\n    private void increment() {\n\t\ta = a+e+i+o+u;\n\t\te = e+i+o+u;\n\t\ti = i+o+u;\n\t\to = o+u;\n\t}
['Java']