[Java] Easy Solution O(n) with Explanation
To find number of substrings which have a vowel at index i:\n\n\t\t\tsubstrings ending with index i:                   i\n\t\t\tsubstrings starting with index i
To find number of substrings which have a vowel at index i:\n\n\t\t\tsubstrings ending with index i:                   i\n\t\t\tsubstrings starting with index i:                 n - i\n\t\t\tsubstrings contains index i in the middle:  i * (n - i - 1) \n\t\t\t\n\t\t\tSo total will be addition of all : i + (n-i) + (i*(n-i-1)) \n\t\t\t\nSolution:\n```\npublic long countVowels(String word) {\n        long n = (long)word.length();\n        long ans = 0;\n        for (int i=0; i<n; i++) {\n            char c = word.charAt(i);\n            if ("aeiou".indexOf(c) >= 0) {\n                ans += i;\n                ans += (n - i);\n                ans += i * (n - i - 1);\n            }\n        }\n        return ans;\n}\n```
['Java']