75. Sort Colors
Intution
This is a classic Dutch National Flag problem. We want to sort the array in-place such that all:
0
s (red) come first,followed by
1
s (white),followed by
2
s (blue).
Instead of counting and rewriting, we use three pointers to partition the array as we iterate through it.
Complexity
Space Complexity
Time Complexity
Code
Last updated