Your question is Longest or Shortest Order Durations. 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.
Implement a solution to find the longest or shortest order durations in an analytics system.
Given a non-empty list of order records and a mode, return the extreme duration and the IDs of every order having that duration. Preserve the input order of IDs when multiple orders tie.
orders is a list of dictionaries with string order_id and non-negative integer duration fields. mode is either "longest" or "shortest". Return a dictionary with duration and order_ids.
def find_order_extreme(orders, mode):