우선순위큐1 [알고리즘] 프로그래머스 | 이중우선순위큐 이중우선순위큐 답: 더보기 힙 하나로 구현하기 from heapq import heappush, heappop def solution(operations): heap = [] for operate in operations: o = operate.split(" ") alpha, num = o[0], int(o[1]) if alpha == "I": heappush(heap, num) elif alpha == "D": if heap and num == -1: heappop(heap) elif heap and num == 1: heap.pop() if len(heap) > 0: return [max(heap), heap[0]] return [0,0] min_heap, max_heap으로 구현하기 from hea.. 2023. 10. 27. 이전 1 다음