I think many of you know about Mo's algorithm. For those, who don't know, please read this blog.
Here, I consider an alternative (and faster) approach of sorting queries in Mo's algorithm.
Table of contents
- Canonical version of the algorithm
- Achieving a better time complexity