Hostel visit Question


whats causing the error

@singhsimran567
image
you are not changing the value of size here

still testcase 1 didn’t pass

@singhsimran567 share the updated code

@singhsimran567 you are increasing your own work…first entering extra elements and then popping extra elements when you dont need more than k elements in the first place.
In the first case, if size of heap >=k, check before pushing the elements. and make sure size of heap does not exceed k at any point.

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.