RMSQ(spoj)

I’m very much new to RMQ, I was trying to learn it. I saw some segment tree tutorial and tried to solve it this question. I think this question is a basic problem of RMQ but I’m not getting the correct answer through my code. Any input would be very much appreciated. Thanks!
question: RMSQ
solution: Solution

if (l>r) why are you returning 0 in query? You should be returning infinity since it is RMQ