Sort Colors

Medium · rating 1250 · Sorting, Two Pointers

The first line has n. The second line has n integers, each 0, 1, or 2. Print them sorted in non-decreasing order, space-separated.

Constraints: 1 ≤ n ≤ 105

Related problems

Open Sort Colors in Code Arena →