Problems
mediumSort an Array of 0s, 1s and 2s
5 Koda Coins

Sort an Array of 0s, 1s and 2s

medium2s limit💾 64 MB

Description

Given an array containing only 0s, 1s, and 2s, sort the array in-place without using any built-in sorting library.


Input Format

  • First line: Array size N.
  • Second line: N integers (0, 1, or 2).

  • Output Format

  • Print the sorted array space-separated.

  • Constraints

  • 1 <= N <= 10^5