Back to problems

Frequency-Priority Error Code Sort

Algorithm · Amazon · Easy

Requirements Function signature: def sort_codes(codes: list[int]) -> list[int]. Input: an integer list of error codes; repeated values may appear. Output: those same values arranged with the least common codes first; when two codes occur equally often, place the numerically lower code ahead of the other. Do not omit or collapse any occurrences: the result must retain the original multiset. Examples

Checking your access…