[Programmers] 코딩테스트 입문 120905. n의 배수 고르기

이지현·2023년 3월 3일
0

Algorithm

목록 보기
49/81
post-thumbnail

✔️ Problem URL

n의 배수 고르기


✔️ Problem

정수 n과 정수 배열 numlist가 매개변수로 주어질 때, numlist에서 n의 배수가 아닌 수들을 제거한 배열을 return하도록 solution 함수를 완성해주세요.


✔️ Code

import java.util.*;

class Solution {
    public int[] solution(int n, int[] numlist) {
        int[] answer = Arrays.stream(numlist).filter(value -> value % n == 0).toArray();
        return answer;
    }
}
profile
2022.08 ~ 2023.09 / 현재 티스토리 이전 : https://jihyun-devstory.tistory.com/

0개의 댓글

Powered by GraphCDN, the GraphQL CDN