
You are given a daily train timetable as a list of departure times (24-hour format HH:MM). Given the current time (also HH:MM), find the most recent departure time that is not later than the current time, and return how many minutes have elapsed since that departure.
If there is no departure earlier than or equal to the current time on the same day, treat it as wrapping to the previous day’s last departure.
departures
: list of strings, each in
HH:MM
(not necessarily sorted)
now
: string in
HH:MM
Return:
last_departure
: the departure time (as
HH:MM
) that most recently occurred relative to
now
minutes_ago
: the number of minutes between
last_departure
and
now
departures = ["01:10", "03:20", "05:20"]
,
now = "03:40"
last_departure = "03:20"
,
minutes_ago = 20
1 <= len(departures) <= 10^5