Sort Colors (Dutch National Flag)
Medium · Arrays & Strings · about 15 minutes
Asked at Microsoft, Amazon, Meta.
An array nums holds only the values 0, 1 and 2 (red, white and blue). Sort it in place in a single pass so that all 0s come first, then 1s, then 2s, without using a library sort. Return the array.