question 139 Built-ins & Sorting · hard
The busiest departure hour
Airport operations staff the security lanes for the busiest hour of the day. Given the scheduled departure times, find the hour with the most departures. If two hours are equally busy, staff the earlier one first. A day with no departures has no busiest hour.
Function
busiest_hour(departures)departuresa list of 24-hour times as text,
"HH:MM" (always two digits each)Returnsthe busiest hour as a whole number from 0 to 23, or
None for no departuresTiesequally busy hours → the earliest hour
Examples
callbusiest_hour(['05:00', '06:15', '05:10', '06:40', '05:55', '17:20', '06:05'])returns5
callbusiest_hour(['13:30'])returns13
callbusiest_hour([])returnsNone