Java O(n) | Visual Explanation
The solution is pretty straightforward once a pattern is visible.\n\nFor n = 2\na => (a, e,i,o,u)\ne => (e,i,o,u)\ni => (i, o, u)\no => (o, u)\nu => (u) \n\n\nT
The solution is pretty straightforward once a pattern is visible.\n```\nFor n = 2\na => (a, e,i,o,u)\ne => (e,i,o,u)\ni => (i, o, u)\no => (o, u)\nu => (u) \n```\n```\nThe resultant strings are:\naa, ae, ai, ao, au\nee, ei, eo, eu\t\t\t\t\nii, io, iu\t\t\t\t\t\t\noo, ou\t\t\t\t\t\nuu\n```\n```\nFor n = 3\naa => (a,e,i,o,u)      5   \nae => (e, i, o, u)     4  \nai => (i, o, u)        3  \nao => (o, u)\t       2  \nau => u\t\t           1  \n\nee => (e,i,o,u)      4   \nei => (i,o,u)\t     3   \neo => (o,u)\t\t     2   \neu => (u)\t\t     1   \n\n\nii =>  (i,o,u)         3   \nio =>  (o,u)\t       2   \niu =>\t  (u)          1   \n\noo =>  (o,u)          2   \nou =>    (u)          1   \n\nuu => (u)\t          1   \n\n```\nThe total comes out to be 35 which is the desired output.\n```\nclass Solution {\n    public int countVowelStrings(int n) {\n        int a,e,i,o,u;\n        a = e = i = o = u = 1;\n        \n        for(int t = 1; t < n; t++){\n            \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```
['Java']