I have m queries and each query I have to reverse the array between given indices L,R.
The input array always contain numbers from 1 to n in sorted order .
query 2,4 will reverse the array between 2 and 4 and the new array will be [1,4,3,2,5]

how to approach the above problem using segment trees.Thanks in advance.

1 Like

Can you provide a link to the problem (to make sure it is not from any ongoing contest) ?

I have updated the post with the link for the problem