Bus Routes
A hard-tier problem at 47% community acceptance, tagged with Array, Hash Table, Breadth-First Search. Reported in interviews at Uber and 8 others.
Bus Routes is a hard graph-search problem that shows up across Uber, TikTok, Snap, and Citadel. The setup looks simple: you're given bus routes (arrays of stops) and need to find the minimum number of buses to take from one stop to another. The trick catches most candidates off guard. The naive approach of treating stops as nodes and building a graph directly fails because the state space explodes. You need to think about buses as nodes instead, not stops. If you hit this live and blank on the inversion, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Bus Routes"
Bus Routes is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe problem requires Breadth-First Search, but the graph construction is unintuitive. Instead of connecting stops to stops, you connect buses to buses based on shared stops. Build a hash table mapping each stop to the set of buses that serve it. From there, run BFS on the bus graph, not the stop graph. Candidates often waste time trying to optimize a stop-to-stop graph, hitting memory and time limits. The common pitfall is overcomplicating the state tracking. Once you flip to bus-level BFS and use a hash table to precompute stop-to-bus membership, the solution clicks. If you haven't drilled the inversion pattern or the hash-table optimization, StealthCoder hedges you on the live assessment by showing the working approach immediately.
Pattern tags
You know the problem.
Make sure you actually pass it.
Bus Routes recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Bus Routes interview FAQ
Why does a stop-to-stop graph fail here?+
A bus route can have 5 to 500 stops. If you connect every stop to every other stop on the same route, you create O(n^2) edges per route, bloating your graph. Bus-to-bus edges, filtered by shared stops, is far sparser. Hash table lookup makes it efficient.
Is this still asked at big tech companies?+
Yes. Uber, TikTok, Snap, and Citadel all report it. It tests graph modeling intuition and BFS implementation under pressure, not just pattern memorization.
What's the trick to the hash table optimization?+
Map each stop to all buses serving it. When you visit a bus, iterate its stops and mark connected buses as unvisited neighbors. This avoids redundant graph construction and keeps lookups O(1).
How hard is this relative to typical BFS problems?+
Hard. Acceptance is about 47 percent. Most candidates know BFS but struggle with the graph design. The inversion from stop-centric to bus-centric thinking is the wall.
Does this relate to other graph problems I should drill?+
Yes. It combines hash table design with BFS traversal. If you're solid on shortest-path BFS and hash-based graph construction, you'll recognize the pattern. Otherwise, the modeling step will cost you time.
Want the actual problem statement? View "Bus Routes" on LeetCode →