Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit414977f

Browse files
add 2063
1 parentf405d9a commit414977f

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2063|[Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2063.java)||Medium||
1112
|2062|[Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2062.java)||Easy||
1213
|2058|[Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2058.java)||Medium||
1314
|2057|[Smallest Index With Equal Value](https://leetcode.com/problems/smallest-index-with-equal-value/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2057.java)||Easy||
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_2063 {
4+
publicstaticclassSolution1 {
5+
/**
6+
* credit: https://leetcode.com/nevergiveup/
7+
*/
8+
publiclongcountVowels(Stringword) {
9+
longans =0;
10+
for (inti =0;i <word.length();i++) {
11+
if (isVowel(word.charAt(i))) {
12+
longleft =i;
13+
longright =word.length() -left -1;
14+
ans += (left +1) * (right +1);
15+
}
16+
}
17+
returnans;
18+
}
19+
20+
privatebooleanisVowel(charch) {
21+
returnch =='a' ||ch =='e' ||ch =='i' ||ch =='o' ||ch =='u';
22+
}
23+
}
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.solutions._2063;
4+
importorg.junit.BeforeClass;
5+
importorg.junit.Test;
6+
7+
importstaticorg.junit.Assert.assertEquals;
8+
9+
publicclass_2063Test {
10+
privatestatic_2063.Solution1solution1;
11+
privatestaticStringword;
12+
privatestaticlongexpected;
13+
14+
@BeforeClass
15+
publicstaticvoidsetup() {
16+
solution1 =new_2063.Solution1();
17+
}
18+
19+
@Test
20+
publicvoidtest1() {
21+
word ="aba";
22+
expected =6l;
23+
assertEquals(expected,solution1.countVowels(word));
24+
}
25+
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp