C# 알고리즘 코드카타

53. 명예의 전당 (1)

잼잼재미 2023. 12. 7. 09:48

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;

public class Solution {
    public int[] solution(int k, int[] score) {
        int[] answer = new int[score.Length];
        List<int> topScore = new List<int>();
        
        for(int i = 0; i < score.Length; ++i)
        {
            topScore.Add(score[i]);
            
            if(topScore.Count > k)
            {
                topScore.Remove(topScore.Min());
            }
            
            answer[i] = topScore.Min();
        }
        
        return answer;
    }
}