#138477
๐ Question ?
https://school.programmers.co.kr/learn/courses/30/lessons/138477#
๐ Answer
class Solution {
fun solution(k: Int, score: IntArray): IntArray {
var list = mutableListOf<Int>()
var answer = mutableListOf<Int>()
for (i in score.indices) {
list.add(score[i])
list.sort()
if (i<k-1) {
answer.add(list[0])
} else {
answer.add(list[i-k+1])
}
}
return answer.toIntArray()
}
}
๐ Result
๐ Comment
ํ๋ ๋ง๋ค ๋ฟ๋ฏ
'Algorithm > Kotlin' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค โข ์ฝํ๋ฆฐ] 2016๋ #12901 (0) | 2023.12.19 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค โข ์ฝํ๋ฆฐ] ์นด๋ ๋ญ์น #159994 (0) | 2023.12.19 |
[ํ๋ก๊ทธ๋๋จธ์ค โข ์ฝํ๋ฆฐ] ์ฝ๋ผ ๋ฌธ์ #132267 (0) | 2023.12.13 |
[ํ๋ก๊ทธ๋๋จธ์ค โข ์ฝํ๋ฆฐ] ํธ๋ ํ์ดํธ ๋ํ #134240 (0) | 2023.12.12 |
[ํ๋ก๊ทธ๋๋จธ์ค - ์ฝํ๋ฆฐ] ๋ด์ #70128 (dot product) (1) | 2023.12.11 |