프로그래머스 - n의 배수 고르기

차관호·2023년 3월 7일
0

문제링크 - 프로그래머스 - n의 배수 고르기

class Solution {
    public int[] solution(int n, int[] numlist) {
        int b = 0;
        for(int i=0;i<numlist.length;i++){
            if(numlist[i]%n==0){
                b++;
            }
        }
        int[] num = new int[b];
        b=0;
        for(int i=0;i<numlist.length;i++){
            if(numlist[i]%n==0){
                num[b] = numlist[i];
                b++;
            }
        }
        return num;
    }
}
profile
안녕하세요 :-)

0개의 댓글