Please read the new rule regarding the restriction on the use of AI tools. ×

Please help with Mos algo time complexity Please help
Difference between en1 and en2, changed 11 character(s)
Hi everyone I was reading article on mos algo from [Mos algo](https://cp-algorithms.com/data_structures/sqrt_decomposition.html).↵
Let's say we have   1e5 and the queries are like (b1,bn)  (b2,b3) (b4,bn)  (b5,b6)  (b7,bn). If we sort the queries according to Mos algorithm where bi represents the block number it seems that the left pointer will always be increasing However the right pointer is jumping between blocks (eg bn to b3, b3 to bn and bn to b6) Wouldnt the right pointer need O(n) time because if we want to go from bi to bn then we have traverse all the elements in all the blocks present between bi to bn Please help what i am getting wrong here  ?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English acash 2024-09-25 06:23:49 11
en1 English acash 2024-09-25 06:23:33 715 Initial revision (published)