Sort 0s 1s 2s Problem

Sort 0s 1s 2s Problem — ExecCode Easy DSA Practice

Solve the Sort 0s 1s 2s problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the input needed to solve Sort 0s 1s 2s. Your task is to compute the required answer and return 0s then 1s then 2s. n, then n values in {0,1,2}.

Examples

Input {"nums": [0, 1, 2, 0, 1]}; Output 0 0 1 1 2. Input {"nums": [2, 2, 0]}; Output 0 2 2. Input {"nums": [0, 1, 2, 0, 1, 2]}; Output 0 0 1 1 2 2

Constraints

O(n) one pass

Practice Sort 0s 1s 2s free on ExecCode. Browse DSA problems, topic map, and placement guides.