Minimum Wait until the Next Bus
Problem statement
Every time is a valid 24-hour HH:MM string. Buses repeat daily. Return the minimum forward wait from current to any scheduled departure, formatted as HH:MM. A bus departing now has wait 00:00; departures earlier today are considered on the next day.
Function
minimumBusWait(schedules: String[], current: String) → StringExamples
Example 1
schedules = ["12:00","13:00"]current = "12:30"return = "00:30"The next bus is 30 minutes away.
Example 2
schedules = ["08:15","09:00"]current = "08:15"return = "00:00"A bus at the current time gives zero wait.
Constraints
1 <= schedules.length <= 100000- All strings use exactly two hour digits, a colon, and two minute digits.