Rollback Mo's Algorithm
Applicable Scenarios
Offline problems where expanding intervals is easier to maintain than shrinking.
Variants exist for "remove-only" Mo's algorithm.
Example Problem: P5906 [Template] Rollback Mo's Algorithm
Given an array, process multiple queries to find the maximum distance between two equal elements within a given interval.
Con ...
Posted on Mon, 14 Sep 2026 16:14:11 +0000 by Azala