All challenges
Algorithm challenge · DSA
Sort Colors
Difficulty
medium
Time
~20m
Format
Single
Grading
Auto-graded
#python#javascript#typescript#go#java#cpp#rust#dsa#two-pointers#sorting
Mission file // read carefullymedium
Given nums containing only 0, 1, 2 (red/white/blue), return them sorted in non-decreasing order. Try a one-pass Dutch-national-flag solution.
[2,0,2,1,1,0] => [0,0,1,1,2,2]
Build with
sortColors(nums: int[]) → int[]PythonJavaScriptTypeScriptGoJavaC++Rust
4 tests · 1 hidden
Auto-graded on submit
Start challenge
Sign in to save your progress.