easy +8 pts

Delete Old Records

Remove records older than a cutoff date while maintaining order.

You are given a list of records. Each record is a tuple `(record_id, date_string)` where `date_string` is in ISO format `'YYYY-MM-DD'`. Implement a function `delete_old_records(records, cutoff_date)` that returns a list of `record_id`s for records whose `date_string` is **on or after** the cutoff date. The original order of records must be preserved in the output. The cutoff date is provided as a string in the same format. You may use Python's `datetime` module if needed.

Constraints

`records` is a non-empty list. Each `date_string` is a valid date in `YYYY-MM-DD` format. `cutoff_date` is a valid date string. The function should not modify the input list. Time complexity: O(n) where n is the number of records.

Example

>>> delete_old_records([(1, '2023-01-10'), (2, '2023-01-05'), (3, '2023-01-15')], '2023-01-10')
[1, 3]
>>> delete_old_records([(10, '2020-12-31')], '2021-01-01')
[]
8 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Parse the cutoff_date string into a `date` object once.
For each record, parse the date_string and compare it to the cutoff date.
Use a list comprehension to keep records with date >= cutoff_date.
Remember to return only the record IDs, not the full tuples.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.