GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesCounting Sort Mailroom

Gamified challenge · Counting sort

Counting Sort Mailroom

Every letter in the sack has a postcode: an integer from 0 to 999. codes lists them in the order they fell out of the sack, with repeats.

Write sortMail(codes) that returns the postcodes sorted from smallest to largest, repeats included. Postcodes are small, so use counting sort: count how many letters go to each postcode, then write each postcode out that many times. That's O(n + k) for n letters and k possible postcodes.

Example: [42, 17, 42, 3, 25, 17] → [3, 17, 17, 25, 42, 42].

Sign in to play Counting Sort Mailroom

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account