FastPrepFastPrep
Problem Brief

Buses in a Bustling Town 🚌

FULLTIMEOA
See Meta online assessment and hiring insights

In a bustling town where buses shuttle passengers throughout the day, the schedule of bus departures is meticulously recorded. Imagine you're standing at the bus stop, checking the time on your watch. You want to know how long ago the last bus departed. But if the day hasn't started yet and the first bus hasn't left, you're out of luck and receive a signal of -1.

Your task is to determine, from the listed departure times and the current time, how many minutes have passed since the last bus departed. Remember, if a bus is scheduled to leave exactly at the current time, it hasn't departed yet.

1Example 1

Input
timeTable = ["12:30", "14:00", "19:55"], moment = "14:30"
Output
30
Explanation
The present moment -> "14:30". The very last bus in the town departed at "14:00", so we can return 30 (literally 30 mins ago) P.S. For original prompt, pls refer to source img.

2Example 2

Input
timeTable = ["00:00", "14:00", "19:55"], moment = "00:00"
Output
-1
Explanation
Unfortunately 😒, there is not buses departed before "00:00" (the bus was supposed to depart at "00:00" hasn't departed yet), so return -1; P.S. For original prompt, pls refer to source image.

3Example 3

Input
timeTable = ["12:30", "14:00", "19:55"], moment = "14:00"
Output
90
Explanation
The present moment is "14:00". And the most recent bus departed at "12:30" (the bus was supposed to go at "14:00" hasn't departed yet), so we return 90. P.S. For original prompt, pls refer to source image.

Constraints

Limits and guarantees your solution can rely on.

Uknown for now
public int bustlingTownBuses(String[] timeTable, String moment) {
  // write your code here
}
Input

timeTable

["12:30", "14:00", "19:55"]

moment

"14:30"

Output

30

Sign in to submit your solution.