Problem :- http://www.codechef.com/MAY13/problems/MSTICK

My solution :- http://www.codechef.com/viewsolution/4165729

// <O(n),O(sqrt(n))>

I implemented the above complexity algorithm given at topcoder

link:- http://www.topcoder.com/tc?d1=tutorials&d2=lowestCommonAncestor&module=Static

Can anyone tell me Why the two classes which i coded for RangeMinimumQuery and RangeMaximumQuery giving wrong answer

PLZ Help