You are viewing a single comment's thread. Return to all comments →
Why this is getting TLE, where as if I create a heap class and acces custom-made delete method which is actually self.heap.remove(element) is ok??
import heapq n = int(input()) heap = [] for _ in range(n): n = input().strip().split() if n[0] == '1': heapq.heappush(heap, int(n[1])) elif n[0] == '2': heap.remove(int(n[1])) else: print(heap[0]) heapq.heapify(heap)
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 →
Why this is getting TLE, where as if I create a heap class and acces custom-made delete method which is actually self.heap.remove(element) is ok??