You are given a list of rental requests, where each request is a pair (pickup_time, return_time). Create cars with consecutive ids starting from 0 and assign every request to a car so that no car has overlapping requests. Record each assigned request in that car's rental_record. Return the final assignment as a list of dictionaries in ascending car id order, where each dictionary has keys 'id' and 'rental_record'. Requests may be given in any order. Assume that return_time == pickup_time is non-overlapping, so a car returned at time t can be reused for another request starting at time t. Your assignment should use the minimum possible number of cars.
Examples
Input: ([],)
Expected Output: []
Explanation: No requests means no cars are created.
Input: ([(5, 8)],)
Expected Output: [{'id': 0, 'rental_record': [(5, 8)]}]
Explanation: A single request needs one car.
Input: ([(1, 4), (2, 3), (4, 6)],)
Expected Output: [{'id': 0, 'rental_record': [(1, 4), (4, 6)]}, {'id': 1, 'rental_record': [(2, 3)]}]
Explanation: At time 4, both cars are free, and the smallest free id is reused.
Input: ([(5, 7), (1, 3), (3, 5), (2, 4)],)
Expected Output: [{'id': 0, 'rental_record': [(1, 3), (3, 5), (5, 7)]}, {'id': 1, 'rental_record': [(2, 4)]}]
Explanation: Sorting by pickup time allows one car to handle the chain 1-3, 3-5, 5-7.
Input: ([(0, 1), (1, 2), (1, 3)],)
Expected Output: [{'id': 0, 'rental_record': [(0, 1), (1, 2)]}, {'id': 1, 'rental_record': [(1, 3)]}]
Explanation: The request ending at time 1 frees a car that can immediately be reused by one of the requests starting at time 1.