Medium

Quiz

#75 Sort Colors

APPROACH

Sort array nums of n items representing red (0), white (1), and blue (2) objects in-place so all reds precede whites, which precede blues. The standard library sort function may not be used.

Example 1:

Input: nums = [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]

Example 2:

Input: nums = [2,0,1]
Output: [0,1,2]
1 of 4
1:00

What is the optimal approach for this problem?