n개 간격의 원소들

gotcha!!·2024년 1월 10일
0

코딩테스트

목록 보기
30/36

문제 링크

import java.util.*;
class Solution {
    public List solution(int[] num_list, int n) {
        List<Integer> answer = new ArrayList<>();
        for(int i = 0; i<num_list.length; i+=n){
            answer.add(num_list[i]);
        }
        return answer;
    }
}
profile
ha lee :)

0개의 댓글