Counting Sort LeetCode Problems: All 8, With Python Solutions

Every problem in this library that LeetCode tags Counting Sort 8 in total, 8 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 8 problems
  • 5 Easy
  • 3 Medium
  • 0 Hard

How Counting Sort problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Counting Sort problems — each one explains the approach, gives a Python template and states its complexity.

  • Sorting — Spend O(n log n) once to buy an ordering that makes the rest of the problem trivial.

Counting Sort problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (5)

#ProblemDifficultyTopics
561Array PartitionEasyGreedy, Array, Counting Sort +1
1051Height CheckerEasyArray, Counting Sort, Sorting
1122Relative Sort ArrayEasyArray, Hash Table, Counting Sort +1
1365How Many Numbers Are Smaller Than the Current NumberEasyArray, Hash Table, Counting Sort +1
2037Minimum Number of Moves to Seat EveryoneEasyGreedy, Array, Counting Sort +1

Medium (3)

#ProblemDifficultyTopics
274H-IndexMediumArray, Counting Sort, Sorting
912Sort an ArrayMediumArray, Divide and Conquer, Bucket Sort +5
1833Maximum Ice Cream BarsMediumGreedy, Array, Counting Sort +1

When the Counting Sort problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.