Next

Sort Items by Risk Severity

TCS NQT Coding Easy

Airport security officials have confiscated several items from passengers at the security checkpoint. All the items have been dumped into a huge box (represented as an array). Each item has a certain amount of risk, categorized as 0, 1, or 2. Your task is to sort the items based on their risk severity values, which range from 0 to 2.

Examples:

Input:
7
[1, 0, 2, 0, 1, 0, 2]

Output:
0 0 0 1 1 2 2

Input:
5
[2, 1, 0, 1, 2]

Output:
0 1 1 2 2

Input:
3
[0, 0, 0]

Output:
0 0 0

Constraints

  • 1 <= N <= 1000
  • 0 <= arr[i] <= 2