I am working on this problem . As I am a newbie in algorithm designing , I wanted to know how can we solve this problem. Please help me in figuring this out in brief. P.S.  A tutorial can be a great help for many other people like me who wants to learn. Thanks In Advance. asked 29 Jun '15, 01:56

you can solve it by using segment tree. For more detail plz see this link:https://www.topcoder.com/community/datascience/datasciencetutorials/rangeminimumqueryandlowestcommonancestor/ answered 29 Jun '15, 08:01

u can use two segment trees one for min and one for max. thats it done. answered 29 Jun '15, 12:46
