Concept Flow - Sort Colors Two Pointer Dutch Flag
Initialize pointers: low=0, mid=0, high=n-1
Check mid <= high?
No→Done
Yes
Inspect nums[mid
Swap nums[low
mid++
Swap nums[mid
Repeat loop
We use three pointers low, mid, and high to sort colors in one pass by swapping 0s to front, 2s to end, and leaving 1s in middle.
