Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

잠 안 올 때 끄적끄적

[프로그래머스/파이썬/python] Lv1. 명예의 전당 (1) 본문

코딩/프로그래머스

[프로그래머스/파이썬/python] Lv1. 명예의 전당 (1)

kerp 2023. 1. 29. 22:15

> 문제

> 코드

def solution(k, score):
    answer = []
    newscore = []
    for sc in score:
        newscore.append(sc)
        newscore.sort(reverse=True)
        answer.append(min(newscore[:k]))
    return answer

금방 풀었다. 

새 리스트에 순서대로 더해서 sort()로 제일 작은 점수 찾으면 끝!