class Solution {
public int[] shuffle(int[] nums, int n) {
//用空间换时间
int[] result = new int[nums.length];
int next = 0;
for (int i = 0; i < n; i++) {
//写入值
result[next] = nums[i];
result[next + 1] = nums[i + n];
next += 2;
}
return result;
}
}
leetcode 1470. 重新排列数组
最新推荐文章于 2024-11-02 14:54:34 发布