I tried constructing RMQ from DFS tree of each node with no parents.
However this TLEs, since there can be O(n) such RMQs.
Is there some way to do it with one RMQ, so each query is O(logn)?
How did you guys solve this one ? Thanks!