Simple java single pass DP O(n)
\n\n\npublic long countVowels(String word) {\n        long cnt = 0;\n        int n = word.length();\n        long dp[] = new long[n+1];\n        Set<Character> 
\n\n```\npublic long countVowels(String word) {\n        long cnt = 0;\n        int n = word.length();\n        long dp[] = new long[n+1];\n        Set<Character> vowels = new HashSet<Character>();\n        vowels.add(\'a\');vowels.add(\'e\');vowels.add(\'i\');vowels.add(\'o\');vowels.add(\'u\'); \n        \n        for (int i=1; i<n+1; i++) {\n            if (vowels.contains(word.charAt(i-1))) {\n                dp[i] = i + dp[i-1];\n            } else {\n                dp[i] = dp[i-1];\n            }\n            cnt+=dp[i];\n        }\n        \n        return cnt;\n    }\n\t```
['String', 'Dynamic Programming', 'Java']