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

Commitd17680c

Browse files
add 1704
1 parent59d0222 commitd17680c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-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+
|1704|[Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1704.java)||Easy|String|
1112
|1700|[Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1700.java)||Easy|Array|
1213
|1694|[Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1694.java)||Easy|String|
1314
|1690|[Stone Game VII](https://leetcode.com/problems/stone-game-vii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1690.java)||Medium|DP|
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.Arrays;
4+
importjava.util.HashSet;
5+
importjava.util.Set;
6+
importjava.util.stream.IntStream;
7+
8+
publicclass_1704 {
9+
publicstaticclassSolution1 {
10+
publicbooleanhalvesAreAlike(Strings) {
11+
Set<Character>vowels =newHashSet<>(Arrays.asList('a','e','i','o','u','A','E','I','O','U'));
12+
intfirstHalfVowelsCount = (int)IntStream.range(0,s.length() /2).filter(i ->vowels.contains(s.charAt(i))).count();
13+
intsecondHalfVowelsCount = (int)IntStream.range(s.length() /2,s.length()).filter(i ->vowels.contains(s.charAt(i))).count();
14+
returnfirstHalfVowelsCount ==secondHalfVowelsCount;
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp