Approach Explanation (o゜▽゜)o☆
- I used three pointers: low=0, mid=0, and high=len(arr)-1.
- I placed 0's at the beginning by swapping with low.
- I left 1's in the middle.
- I placed 2's at the end by swapping with high.
- I repeated until mid-crossed high, and the array was sorted.
Methods Used ( ノ ^-^)ノ
- Dutch National Flag algorithm (single pass)
- Three-pointer technique (low, mid, high)
- Constant space (no extra array used)

Top comments (0)