I recently read the tutorial on MO’s algorithm and found that the time complexity of mo’s algorithm is O(q*(n/k)+nk) 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 qsqrt(n) which is 2*sqrt(n). Please ,someone clarify my doubt!
Hope it helps!!