Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dalcon10028/2c216e1753e9f281474a60f4df7a62c5 to your computer and use it in GitHub Desktop.
Save dalcon10028/2c216e1753e9f281474a60f4df7a62c5 to your computer and use it in GitHub Desktop.
프로그래머스 코딩테스트 연습 Level1 - 나누어 떨어지는 숫자 배열 [ Java ]
import java.util.*;
class Solution {
public int[] solution(int[] arr, int divisor) {
LinkedList<Integer> list = new LinkedList<>();
Arrays.sort(arr);
for (int i : arr)
if(i%divisor==0)
list.add(i);
if(list.isEmpty()) list.add(-1);
return list.stream().mapToInt(i->i).toArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment