Arrays medium time O(n) space O(1)
Dutch National Flag
With values limited to 0, 1 and 2, keep settled 0s on the left and settled 2s on the right, sorting the middle. One pass with low/mid/high pointers places every value.
Values are only 0, 1 or 2. Three pointers: low, mid, high.
1 / 11
Practice
Machine twin: /dsa-viz-v2/dutch-national-flag.json — the full deterministic run as structured data.