75. Sort Colors

Practice Sort Colors for free on NudgeCode: Medium, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

nums holds only the values 0, 1 and 2. Rearrange it in place so all 0s come first, then all 1s, then all 2s. Don't use a library sort, and don't return anything. Try for one pass with O(1) extra space.

Example

nums = [2,0,2,1,1,0]  ->  [0,0,1,1,2,2]

Constraints