입출력 예시
k | score | result |
3 | [10, 100, 20, 150, 1, 100, 200] | [10, 10, 10, 20, 20, 100, 100] |
4 | [0, 300, 40, 300, 20, 70, 150, 50, 500, 1000] | [0, 0, 0, 0, 20, 40, 70, 70, 150, 300] |
나의 코드
def solution(k, score):
sorted_score = []
answer = []
for i in range(len(score)):
sorted_score.append(score[i])
sorted_score.sort(reverse=True)
honor = sorted_score[:k]
answer.append(honor[-1])
return answer
Python
복사
다른 풀이
Python
복사