💻
using System.Collections.Generic;
using System;
public class Solution {
public int[] solution(int[] arr, int divisor) {
int[] answer;
List<int> list = new List<int>();
for(int i=0; i<arr.Length; i++)
{
if(arr[i]%divisor==0) list.Add(arr[i]);
}
if(list.Count != 0)
{
list.Sort();
answer = list.ToArray();
}
else
{
answer = new int[] {-1};
}
return answer;
}
}
'프로그래머스 > Lv.1' 카테고리의 다른 글
[프로그래머스 C#] 하샤드 수 (0) | 2023.09.02 |
---|---|
[프로그래머스 C#] 없는 숫자 더하기 (0) | 2023.09.02 |
[프로그래머스 C#] 수박수박수박수박수박수? (0) | 2023.08.29 |
[프로그래머스 C#] 정수 내림차순으로 배치하기 (0) | 2023.08.28 |
[프로그래머스 C#] 약수의 합 (0) | 2023.08.28 |