Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 537c3fb

Browse files
authored
Create Vowels of All Substrings.java
1 parent 494198f commit 537c3fb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Medium/Vowels of All Substrings.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public long countVowels(String word) {
3+
long sum = 0;
4+
long n = word.length();
5+
for (int i = 0; i < n; i++) {
6+
if ("aeiou".indexOf(word.charAt(i)) != -1) {
7+
sum += (i + 1) * (n - i);
8+
}
9+
}
10+
return sum;
11+
}
12+
}

0 commit comments

Comments
 (0)