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;
}
}
'C# 알고리즘 코드카타' 카테고리의 다른 글
55. 카드 뭉치 (0) | 2023.12.11 |
---|---|
54. 2016년 (0) | 2023.12.08 |
52. 콜라 문제 (1) | 2023.12.07 |
51. 푸드 파이트 대회 (0) | 2023.12.06 |
50. 가장 가까운 같은 글자 (1) | 2023.12.06 |