Loading problem…
Each entry in routes lists the stops visited by one bus, repeating forever. Start at source without being on a bus and travel to target using buses only.
Return the fewest buses you must board. Riding through multiple stops on one bus still counts as one bus. Transfers are possible at shared stops. Return 0 if source equals target, and -1 if the trip is impossible.
Example 1:
Example 2: