Back to Practice Dashboard
DSA SectionEasy
Radix Sort
Learn how to solve the 'Radix Sort' problem. This detailed resource details brute force and optimized approaches.
Problem Statement
Easy
Write a function radix_sort(arr) that sorts a list of non-negative integers arr using the Radix Sort algorithm (using counting sort as the stable sorting subroutine) and returns the sorted list.
Constraints
- •0 <= len(arr) <= 1000
- •0 <= arr[i] <= 10^6
Examples
Example 1
Input
arr = [170, 45, 75, 90, 802, 24, 2, 66]
Output
[2, 24, 45, 66, 75, 90, 170, 802]
Explanation
Sorting is performed digit by digit from least significant digit (LSD) to most significant digit (MSD).
Need a Hint?
Analyze the input constraints. Try sorting first (O(n log n)) or using a hash map/set to track seen elements in O(n) time.
Edge Cases to Watch
- Empty list or null input variables
- Single item lists/arrays
- Extremely large input bounds causing integer or stack overflow
Ready to Solve?
Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.