What is wrong with my code?
@alankrit.agr99 you should use a MAX heap…you are using a min heap.
also why is the while loop for i<k?? there are q queries…k is not the number of queries.
why the max heap? we have to arrange the elements on every insertion in an ascending order.
If you are doing it by the maxheap approach, at any case maxm size of your heap will be k… so complexity will be O(nlogk)
Whereas with min heap…maxm size of your heap will be n…So complexity will be O(n log n)
Refer this Hostel Visit- TLE