Solve this to show you know the material and jump straight to Unit 5. Everything before it counts as cleared.
When values are small integers, sorting can beat O(n log n). Implement a stablecounting_sort(items, key, max_key) where key(item) returns an integer in 0..max_key:
count each key
turn counts into starting positions (prefix sums)
place items into the output in input order
Return a new list.
#sorting#linear-time2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit