We have given that at 2 as a input we have to consider 2 as kth element but it is showing k=3 in explanation
Doubt in explanation

hello @anubhavb11
if u r talking about this ->

test case then here k is 3 only (check highlighted part)

getting tle becuase you r running while loop infinite time.
u will be given only q queries , so run while only for q times.
also
use long long in place of int to avoid range overflow

declare them (highlighted part) as long long
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.