Test case 4 not passing
in last test case you are getting TLE(time limit Exceed)
this is because in print_kth()
you are passing priority_queue by value so it copy whole content every time and hence give TLE
best way to solve this question is using max heap
you can see the implementation below in reference code
Reference Code
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.