Sort Colors — Dutch National Flag
Three pointers carve the array into 0s, 1s, and 2s in a single pass. A 0 is swapped to the left region, a 2 to the right region, and a 1 is left alone.
Try:
← Prev
Next →
▶ Play
Reset