Hint please - MAX QUERY

Trying to solve using min segment tree and adding conditions but cannot get correct answer . Can you please provide a hint

This is a harder problem of segment trees. In this, we will maintain complete arrays at each node in a sorted manner.
Since the arrays at each node are sorted, we can apply binary searches.

To merge two arrays, you can use inbuilt merge function as well to save time and code.

Please have a look at this code to get an idea.

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.