[프로그래머스]배열 자르기

박예림·2023년 2월 28일
0

코테

목록 보기
21/132

class Solution {
    public int[] solution(int[] numbers, int num1, int num2) {
        int[] answer = new int[num2-num1+1];
        int n = 0;
        for (int i = num1; i < num2+1; i++) {
            answer[n] = numbers[i]; //순서 중요!
            n++;
        }
        return answer;
    }
}
profile
응애 나 아기개발자

0개의 댓글

Powered by GraphCDN, the GraphQL CDN