We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cfbda22 commit 84c58b8Copy full SHA for 84c58b8
kojungbeom/Programmers/Level3/이중우선순위큐.py
@@ -0,0 +1,20 @@
1
+import heapq
2
+def solution(operations):
3
+ answer = []
4
+ heap = []
5
+ for o in operations:
6
+ command, value = o.split()
7
+ if command == "I":
8
+ heapq.heappush(heap, int(value))
9
+ else:
10
+ if heap:
11
+ if value == '1':
12
+ heap.sort()
13
+ heap.pop()
14
+ elif value == '-1':
15
+ heapq.heappop(heap)
16
17
+ answer = [max(heap), min(heap)]
18
19
+ answer = [0, 0]
20
+ return answer
0 commit comments