Java : 0 ms Faster than 100%, Easy to understand with explanation
Time Complexity - O(n)\nSpace Complexity - O(1)\n\nOn carefully observing the sequence getting formed you will notice a pattern here:\n\nFor n = 1 : a , e , i, 
Time Complexity - O(n)\nSpace Complexity - O(1)\n\nOn carefully observing the sequence getting formed you will notice a pattern here:\n\nFor n = 1 : a , e , i, o, u  \nString starting with a = 1, e  = 1, i = 1, o = 1, u = 1 : Total = 5\n\nFor n = 2 : aa, ae, ai, ao, au, ee, ei, eo, eu, ii, io, iu, oo, ou, uu \nString starting with a = 5, e = 4, i = 3, o = 2, u = 1 : Total = 15\n\nFor n = 3 : aaa, aae, aai, aao, aau, aee, aei, aeo, aeu, aii, aio, aiu, aoo, aou, auu, eee, eei, eeo,eeu,eii, eio, eiu, eoo, eou, euu, iii, iio, iiu, ioo, iou, iuu, ooo, oou, ouu, uuu : Total = 35\n\nOn carefully observing :\nFor n = 2 : All the sequence formed count is equal to sum of previous sequences (i.e. n  = 1) starting with a, e, i, o, u\n                 a =  a + e + i + o + u (1 + 1 + 1 + 1+ 1) = 5\n\t\t\t\t e = e + i + o +u (1 + 1+ 1+ 1) = 4\n\t\t\t\t  i = i + o + u (1 + 1 + 1) = 3\n\t\t\t\t  o = o + u ( 1 + 1) = 2\n\t\t\t\t  u = u (1) = 1\n\t\t\t\t  Total = a + e + i + o + u = 5 + 4 + 3 + 2 + 1 = 15\n\t\t\t\t  \nFor n = 3: All the sequence formed count is equal to sum of previous sequences (i.e. n = 2) starting with a, e, i, o, u \n                 a =  a + e + i + o + u (5 + 4 + 3 + 2+ 1) = 15\n\t\t\t\t e = e + i + o +u (4 + 3+ 2+ 1) = 10\n\t\t\t\t  i = i + o + u (3 + 2 + 1) = 6\n\t\t\t\t  o = o + u ( 2 + 1) = 3\n\t\t\t\t  u = u (1) = 1\n\t\t\t\t  Total = a + e + i + o + u = 15 + 10 + 6 + 3 + 1 = 35\n\t\t\t\t  \n\t\t\t\t  \n\n```\nclass Solution {\n    public int countVowelStrings(int n) {\n        int a = 1;\n        int e = 1;\n        int i = 1;\n        int o = 1;\n        int u = 1;\n        while(n-- > 1){\n            a = a + e + i + o + u;\n            e = e + i + o + u;\n            i = i + o + u;\n            o = o + u;\n            u = u;\n        }\n        return a + e + i + o + u;\n        \n    }\n}\n```\n
['Java']