There is a bus stop near your home. The daily bus routes are given in the String[] buses, each element of which is formatted "START INTERVAL COUNT" (quotes for clarity). Each element describes a single route consisting of COUNT buses. The first bus on the route comes at time START, and the interval between each pair of consecutive buses is INTERVAL. In other words, the buses on that route come at times START, START + INTERVAL, ..., START + (COUNT - 1) * INTERVAL.
You arrive at the bus stop at time arrivalTime. Return the amount of time you must wait before the next bus (from any of the given routes) comes to your stop. If there's a bus at the stop at the exact moment you arrive, return 0. If no buses come for the rest of the day, return -1.
|