Code is giving TLE for 1 Test Case

Code Link - https://ide.codingblocks.com/s/227412
Kindly resolve

hello @7nishit
for each query of type 2 , u are performing k number of operations and for q such query ,
u code will perform q*k operation which is the reason for tle.

to optmise it use max heap.

In maxHeap we will get the biggest element as root, how will that help as we need to find the kth nearest element . Kindly explain in bit more detail.

yeah on top of max heap u will get biggest value.
now let say a new element come whose value is less than that biggest value in that case we will pop out that biggest value from heap and push new element into heap.

in this way we will be able to main k smallest number in our heap.

please try this on some test case u will get a better clarity.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.