Loading...
Loading...
Loading...
A task list uses only three priority levels, 0, 1 and 2. Sort the list in one pass without calling sort, using three pointers. Print the sorted list.
Example
Input
2 0 2 1 1 0
Output
0 0 1 1 2 2
Try the problem first. Open one hint at a time.
Keep zeros before low, twos after high, and let mid scan the unknown part.
After swapping a 2 to the right do not move mid, because the swapped-in value is not checked yet.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor