class Solution {
public int[] shuffle(int[] nums, int n) {
int len = nums.length;
int[] res = new int[len];
int resIndex = 0;
for(int i=0; i < len/2; i++){//배열 중간까지만 진행
res[resIndex] = nums[i];//첫번째값
res[++resIndex] = nums[i+n];//두번째값은 n만큼 더한 위치
resIndex++;
}
return res;
}
}
'개발 > CodingTest' 카테고리의 다른 글
LeetCode - Min Stack (0) | 2020.06.26 |
---|---|
Hackerrank - Utopian Tree (0) | 2020.06.25 |
Hacckerrank - The Hurdle Race (0) | 2020.06.25 |
Hacckerrank - Halloween Sale (0) | 2020.06.25 |
Hackerrank - Prime Checker (0) | 2020.06.05 |