Mixed input
Input
arr = [2, 0, 2, 1, 1, 0]
Output
[0, 0, 1, 1, 2, 2]
After sorting 0s come first, then 1s, then 2s.
Full lesson preview
Reorder an array consisting only of 0s, 1s, and 2s into non-decreasing order using the Dutch National Flag algorithm.
Problem statement
Task
Examples
Input
arr = [2, 0, 2, 1, 1, 0]
Output
[0, 0, 1, 1, 2, 2]
After sorting 0s come first, then 1s, then 2s.
Input format
Output format
Constraints
Samples
Input
[1, 0, 2]
Output
[0, 1, 2]
Simple case with one of each value.