쉬운문제라 설명은 생략
import java.util.*;
class Solution {
public int[] solution(int[] arr, int divisor) {
int[] answer = {};
ArrayList <Integer> tt = new ArrayList<>();
if(divisor == 1) {
Arrays.sort(arr);
return arr;
}
for(int i=0 ; i<arr.length ; i++) {
if(arr[i]%divisor == 0) {
tt.add(arr[i]);
}
}
if(tt.size() == 0) {
return (new int[] {-1});
}
answer = new int[tt.size()];
for(int i=0 ; i<tt.size() ; i++) {
answer[i] = tt.get(i);
}
Arrays.sort(answer);
return answer;
}
}