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

Commit2c39cc4

Browse files
add 1968
1 parent24a6bbb commit2c39cc4

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-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+
|1968|[Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1968.java)||Medium||
1112
|1967|[Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1967.java)||Easy||
1213
|1961|[Check If String Is a Prefix of Array](https://leetcode.com/problems/check-if-string-is-a-prefix-of-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1961.java)||Easy||
1314
|1957|[Delete Characters to Make Fancy String](https://leetcode.com/problems/delete-characters-to-make-fancy-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1957.java)||Easy|String|
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.Arrays;
4+
5+
publicclass_1968 {
6+
publicstaticclassSolution1 {
7+
publicint[]rearrangeArray(int[]nums) {
8+
Arrays.sort(nums);
9+
int[]result =newint[nums.length];
10+
intj =1;
11+
for (inti =0;i <nums.length /2;i++) {
12+
result[j] =nums[i];
13+
j +=2;
14+
}
15+
j =0;
16+
for (inti =nums.length /2;i <nums.length;i++) {
17+
result[j] =nums[i];
18+
j +=2;
19+
}
20+
returnresult;
21+
}
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.common.utils.CommonUtils;
4+
importcom.fishercoder.solutions._1968;
5+
importorg.junit.BeforeClass;
6+
importorg.junit.Test;
7+
8+
publicclass_1968Test {
9+
privatestatic_1968.Solution1solution1;
10+
11+
@BeforeClass
12+
publicstaticvoidsetup() {
13+
solution1 =new_1968.Solution1();
14+
}
15+
16+
@Test
17+
publicvoidtest1() {
18+
CommonUtils.printArray(solution1.rearrangeArray(newint[]{1,2,3,4,5}));
19+
}
20+
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp