We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ec11c61 commit 972ef02Copy full SHA for 972ef02
2 files changed
프로그래머스/1/138477. 명예의 전당 (1)/README.md
@@ -4,7 +4,7 @@
4
5
### 성능 요약
6
7
-메모리: 10.1 MB, 시간: 0.01 ms
+메모리: 11.5 MB, 시간: 0.26 ms
8
9
### 구분
10
@@ -16,7 +16,7 @@
16
17
### 제출 일자
18
19
-2024년 07월 12일 17:28:23
+2026년 07월 25일 15:14:12
20
21
### 문제 설명
22
프로그래머스/1/138477. 명예의 전당 (1)/명예의 전당 (1).py
@@ -1,9 +1,11 @@
1
+import heapq
2
+
3
def solution(k, score):
- q = []
- answer = []
- for s in score:
- q.append(s)
- if (len(q) > k):
- q.remove(min(q))
- answer.append(min(q))
- return answer
+ h = []
+ ans = []
+ for i in score:
+ heapq.heappush(h, i)
+ if len(h) > k:
+ heapq.heappop(h)
+ ans.append(h[0])
11
+ return ans
0 commit comments