Minutes since the Latest Departed Bus
Problem statement
Every value is a valid 24-hour HH:MM time on the same day. Among departures no later than current, find the latest and return how many minutes have elapsed since it. A departure exactly at current returns 0. Return -1 when no bus has departed yet.
Function
minutesSinceLatestBus(schedule: String[], current: String) → intExamples
Example 1
schedule = ["08:00","09:30","12:00"]current = "10:00"return = 30The 09:30 bus departed thirty minutes earlier.
Example 2
schedule = ["08:00"]current = "08:00"return = 0An exact departure gives zero minutes.
Constraints
1 <= schedule.length <= 100000- Every time is exactly five characters in
HH:MMform.