You are viewing a single comment's thread. Return to all comments →
Python. Possibly not the intended solution.
import heapq q = int(input()) heap = [] deleted = set() for _ in range(q): line = input().split() command = line[0] if len(line) > 1: val = int(line[1]) if command == "1": if val in deleted: deleted.remove(val) else: heapq.heappush(heap, val) elif command == "2": deleted.add(val) elif command == "3": x = heap[0] while x in deleted: heapq.heappop(heap) deleted.remove(x) x = heap[0] print(x)
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
Python. Possibly not the intended solution.