• + 1 comment

    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)