Fewest Bus Rides Between Two Stops

Asked at Uber · Coding Questions · Difficulty: Hard · Last asked Jun 8, 2026

A city runs several buses, and each bus drives the same loop of stops forever. You start at one stop and want to reach another. You may ride a bus for as long as you like and change buses at any stop two routes share. Return the fewest buses you must board to get there.

Loading the problem…