코린이의 소소한 공부노트

[프로그래머스/Lv.0] 순서 바꾸기 본문

코딩테스트 풀이/JAVA

[프로그래머스/Lv.0] 순서 바꾸기

무지맘 2023. 5. 1. 13:53

1. Input, Output, Example

- num_listn+1번째부터의 원소들과 n 번째까지의 원소들로 나눠 n+1번째부터의 원소들을 n 번째까지의 원소들 앞에 붙인 리스트를 반환

 

2. Constraint

1) 2 num_list의 길이 30

2) 1 num_list의 원소 9

3) 1 n num_list의 길이

 

3. Code

1) 첫 코드(2023/05/01)

class Solution {
    public int[] solution(int[] num_list, int n) {
        int[] answer = new int[num_list.length];
        System.arraycopy(num_list,n,answer,0,num_list.length-n);
        System.arraycopy(num_list,0,answer,num_list.length-n,n);
        return answer;
    }
}