In the postal sorting office of Prime City, the Postman sorts packages by their numeric zip codes. Radix sort processes each digit from least significant to most significant, using counting sort as a stable subroutine for each digit position. "Radix sort sorts numbers digit by digit," the Postman explains. "Start from the least significant digit, sort using counting sort, then move to the next digit. After processing all digits, the numbers are fully sorted. It runs in O(d * (n + k)) where d is the number of digits and k is the base." Given an array of N non-negative integers, sort them using radix sort. Output the sorted array, space-separated. Constraints: 1 <= N <= 10^5, 0 <= array[i] <= 10^9 Input: 5 170 45 75 90 802 Output: 45 75 90 170 802 Input: 3 3 1 2 Output: 1 2 3
Constraints:
1 <= N <= 10^5, 0 <= array[i] <= 10^9
Tags:
