Your question is Implement In-Memory DB With TTL. 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.
In-Memory DB: Implement set, get, and delete methods with TTL functionality.
Implement run_commands(commands), which processes operations in order. Each set command provides a key, value, timestamp, and positive TTL. A key expires when current_time >= set_timestamp + ttl. get returns the value or None, while delete removes the key if present. Return the results of all get commands in order.
Input commands use ['set', key, value, timestamp, ttl], ['get', key, timestamp], and ['delete', key, timestamp]. Keys and values are strings, and timestamps are nonnegative integers.
def run_commands(commands):