Skip to content

Instantly share code, notes, and snippets.

@cg4jins
Created July 9, 2019 14:47
Show Gist options
  • Save cg4jins/c3503eaed4128f9ac06cae823d152dd0 to your computer and use it in GitHub Desktop.
Save cg4jins/c3503eaed4128f9ac06cae823d152dd0 to your computer and use it in GitHub Desktop.
class Solution {
fun solution(arr: IntArray, divisor: Int): IntArray {
var answer = arrayListOf<Int>()
for (ar in arr){
if (ar % divisor == 0){
answer.add(ar)
}
}
if (answer.size == 0){
answer.add(-1)
}
return answer.sorted().toIntArray()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment