Skip to content

Commit fa06de2

Browse files
committed
1470. 重新排列数组
1 parent 75bc4f1 commit fa06de2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.gatsby;
2+
3+
/**
4+
* @ClassName: _1470ShuffleTheArray
5+
* @Description: leetcode 1470 重新排列数组
6+
* @author: Gatsby
7+
* @date: 2022/7/11 10:44
8+
*/
9+
10+
public class _1470ShuffleTheArray {
11+
public int[] shuffle(int[] nums, int n) {
12+
int[] res = new int[2 * n];
13+
int x = 0;
14+
int y = n;
15+
for (int i = 0; i < 2 * n; ) {
16+
res[i++] = nums[x++];
17+
res[i++] = nums[y++];
18+
}
19+
return res;
20+
}
21+
}
22+
23+

0 commit comments

Comments
 (0)