240816

문제 : λͺ…μ˜ˆμ˜ μ „λ‹Ή (1) λ‚œμ΄λ„ : Lv.1

풀이

   function solution(k, score) {
    var answer = [];
    
    let array = []
    
    for(let i = 0; i < score.length; i++) {
        if(i < k) {
            array[i] = score[i]
            answer.push(Math.min(...array))
        } else {
            array[i] = score[i]
            array.sort((a,b) => b-a)
            answer.push(array[k-1])
        }
    }
    
    return answer
}

Last updated