I recently read the tutorial on MO's algorithm and found that the time complexity of mo's algorithm is O(q*(n/k)+n*k) where k is the block size and q is the number of queries. But ,how can it be so? For example- If i take q=2 and the ranges to be [1,n] and [n-1,n]. Then ,obviously the left pointer will have to move approx n cells and not q*sqrt(n) which is 2*sqrt(n). Please ,someone clarify my doubt!