โ† Amazon questions

Sorting algorithm selection

Filed under Amazon

Free read 1 of 3

Since the range [0, 100] is small and constant, we can use Counting Sort.

The question

Given an array of integers where values are in the range [0, 100], identify the most efficient sorting algorithm.

Constraints

  • Range of values is small and fixed.
  • Must be efficient in time and space.

Approach

  1. Since the range [0, 100] is small and constant, we can use Counting Sort.

Tips

  • What they are testing: Explain why comparison-based sorts (O(n log n)) are inferior to non-comparison sorts here.
  • Common mistake: Suggesting QuickSort or MergeSort without acknowledging the constraints.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.