You are given an array nums containing 0s, 1s, and 2s, representing three colors.
Sort the array in-place so that all 0s come first, then 1s, and then 2s.
Do not use any built-in sort function.
Input: nums = [1,2,0,2,1,0,1]
Output: [0,0,1,1,1,2,2]
Explanation:
All the 0s are first, followed by 1s, then 2s.
Input: nums = [2,1,0,1]
Output: [0,1,1,2]
Accepted:
Submission: