Mo's Algorithm Game — Offline Block Query Sorting
Sort offline range queries by (floor(L / B), R) to minimize sliding-window pointer movement to O((N+Q)sqrt(N)).
Time Complexity: O((N + Q) sqrt(N))
Study the algorithm · Watch Visualizer · All Algorithm Games