Counting sort

What are the counts for 0, 1, 2, and 3?

Examples

Worked example

Input
[3, 1, 3, 0] with values from 0 to 3
Expected output
[1, 1, 0, 2]

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

There is one 0, one 1, no 2, and two 3s.

Back to the lesson