
정수 리스트 num_list와 정수 n이 주어질 때, num_list를 n 번째 원소 이후의 원소들과 n 번째까지의 원소들로 나눠 n 번째 원소 이후의 원소들을 n 번째까지의 원소들 앞에 붙인 리스트를 return하도록 solution 함수를 완성해주세요.
num_list의 길이 ≤ 30num_list의 원소 ≤ 9n ≤ num_list의 길이| num_list | n | result |
|---|---|---|
| [2, 1, 6] | 1 | [1, 6, 2] |
| [5, 2, 1, 7, 5] | 3 | [7, 5, 5, 2, 1] |
입출력 예 #1
입출력 예 #2
import java.util.*;
class Solution {
public int[] solution(int[] num_list, int n) {
List<Integer> answer = new ArrayList<>();
for (int i = n; i < num_list.length; i++) {
answer.add(num_list[i]);
}
for (int i = 0; i < n; i++) {
answer.add(num_list[i]);
}
return answer.stream().mapToInt(i->i).toArray();
}
}