Sort Colors

Medium
ArrayTwo PointersSortingMicrosoftMeta
Given an array containing only 0, 1, and 2, print the values in sorted order. Input format: - First line: n - Second line: n integers, each one 0, 1, or 2 Print the sorted values on one line.

Constraints

1 <= n <= 10^5
nums[i] is 0, 1, or 2

Sample tests

Sample 1

Sample 2

Sign in to submit