I saw your solution, you are running a loop in L to R in each query, it will easily get timed out if difference between L to R is fairly large for each query irrespective of the array elements.
I know my solution is not efficient thatās why Iām shocked to know it is AC in O(nq) for some peoplesā¦