출처 : https://leetcode.com/problems/shuffle-the-array/
Given the array nums
consisting of 2n
elements in the form [x1,x2,...,xn,y1,y2,...,yn]
.
Return the array in the form [x1,y1,x2,y2,...,xn,yn]
.
class Solution {
public int[] shuffle(int[] nums, int n) {
int[] res = new int[nums.length];
int index = 0;
for (int i = 0; i < n; i++) {
res[index++] = nums[i];
res[index++] = nums[i + n];
}
return res;
}
}