Getting TLE in Max Query 1

I have done in the same way as shown in the hint video.
I have build the segment tree only once.

Code link- https://ide.codingblocks.com/s/197314

Maybe due to binary search after getting the query arraylist as if array contains equal elements then binary search can give any index , but you need the lowerbound for k.
Do binary search yourself.

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.