← Back

Counting Sort

Count frequency of small-range keys then prefix sum.

sortingcounting-sortUpdated 2025-09-01

Complexity

  • O(n + k) where k = range

Stable

  • Reconstruct using cumulative counts