In this question can’t we build tree for every query?
Max query Problem
I mean for every value of k, we create a segment tree that checks specifically for that particular k
building tree be O(n)
if you build for each query then,
in this question u will get TLE