Your question is Deduplicate Automated Test Results. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a list of test execution records, return the final unique failures after deduplication. Each record is a dictionary with keys test_id, status, timestamp, and message. Keep only records where status == "FAIL", and if the same test_id appears multiple times as a failure, keep only the most recent one by timestamp. Return the result sorted by ascending test_id.
def deduplicate_failures(records):