Problem
Problem URL : 나누어 떨어지는 숫자 배열
[1] Answer Code (18. 07. 22)
vector<int> solution(vector<int> arr, int divisor) {
vector<int> answer;
sort(arr.begin(), arr.end());
for(int i=0; i<arr.size(); i++){
if(arr[i] % divisor == 0)
answer.push_back(arr[i]);
}
if(answer.size() == 0)
answer.push_back(-1);
return answer;
}
[1] Answer Code (18. 07. 22)
- Programmers Problem