Java | Derived Formula | Easy & Concise
\nclass Solution {\n    public long countVowels(String word) {\n        long n = word.length() ;\n        long result = 0 ;\n        \n        for (int i = 0; i
```\nclass Solution {\n    public long countVowels(String word) {\n        long n = word.length() ;\n        long result = 0 ;\n        \n        for (int i = 0; i < n; i++) {\n            char ch = word.charAt(i) ;\n            if (ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\')\n                result += (i+1)*(n-i) ;\n        }\n        \n        return result ;\n    }\n}\n```
['Java']