Your question is Deduplicate Records by Composite Key. 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 record dictionaries records, a list of field names key_fields that form a composite key, and a field name timestamp_field, return a new list with duplicate records removed. Records are duplicates if all values in key_fields match. For each composite key, keep only the record with the largest value in timestamp_field.
def deduplicate_records(records, key_fields, timestamp_field):