
Programmers / 3단계 / 이중우선순위큐 / python / heapq
·
코딩테스트/programmers (python)
코딩테스트 연습 - 이중우선순위큐 | 프로그래머스 스쿨 (programmers.co.kr) 모범 답안 import heapq def solution(operations): q = [] for i in operations: oper, num = i.split() num = int(num) if oper == 'I': heapq.heappush(q, num) elif oper == 'D' and num == 1: if len(q) != 0: q.remove(max(q)) else: if len(q)!=0: heapq.heappop(q) if len(q) == 0: answer = [0,0] else: answer = [max(q), heapq.heappop(q)] return answer 학습한 것 heap..