Skip to content

Commit

Permalink
1470. 重新排列数组
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMer7 committed Jul 11, 2022
1 parent 75bc4f1 commit fa06de2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/com/gatsby/_1470ShuffleTheArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.gatsby;

/**
* @ClassName: _1470ShuffleTheArray
* @Description: leetcode 1470 重新排列数组
* @author: Gatsby
* @date: 2022/7/11 10:44
*/

public class _1470ShuffleTheArray {
public int[] shuffle(int[] nums, int n) {
int[] res = new int[2 * n];
int x = 0;
int y = n;
for (int i = 0; i < 2 * n; ) {
res[i++] = nums[x++];
res[i++] = nums[y++];
}
return res;
}
}


0 comments on commit fa06de2

Please sign in to comment.