AlgoFrames

Fill the count array

Warm-up · Trace the algorithm · about 6 min

Follow counting sort on [3, 1, 3, 0, 2, 1, 3]. Before each count cell changes, type the number it will hold afterwards.

Example 1

Input:

{"values":[3,1,3,0,2,1,3]}

Output:

[1,2,1,3]

The final counts for keys 0 to 3.

Constraints

  • The trace uses the input shown.

Learn the idea first: Counting sort, a visual lesson.

More Counting sort problems