Hotel visit problem

I HAVE TRIED TO SOLVE THE 2ND TESTCASE BUT I AM NOT GETTING WERE THE CODE IS GOING WRONG

think like a bucket , store all elements in it and then find the kth largest, simple