Pattern · Breadth-First Search

Breadth-First Search interview questions

165 breadth-first search problems tagged across recent interview reports. Drilled most heavily by doordash, linkedin, and snap.

Founder's read

Breadth-First Search is a graph traversal pattern that explores nodes layer by layer, making it essential for level-based problems, shortest paths, and connected component discovery. With 165 problems tagged across this pattern and heavy emphasis at DoorDash (63 problems), LinkedIn (60), and Snap (53), BFS isn't optional, it's a baseline competency that interviewers expect you to recognize and implement cleanly under pressure. If you freeze on a BFS variant during your live assessment, StealthCoder solves it invisibly while you stay calm.

Most-asked breadth-first search problems

#ProblemDiff# Companies
01Coin ChangeMEDIUM37
02Course ScheduleMEDIUM34
03Course Schedule IIMEDIUM33
04Binary Tree Zigzag Level Order TraversalMEDIUM19
05Evaluate DivisionMEDIUM17
06Binary Tree Level Order TraversalMEDIUM15
07Clone GraphMEDIUM14
08Alien DictionaryHARD13
09Binary Tree Right Side ViewMEDIUM13
10All Nodes Distance K in Binary TreeMEDIUM10
11Bus RoutesHARD9
12Cheapest Flights Within K StopsMEDIUM9
13Accounts MergeMEDIUM8
14Amount of Time for Binary Tree to Be InfectedMEDIUM8
15Flood FillEASY7
1601 MatrixMEDIUM5
17Binary Tree Vertical Order TraversalMEDIUM4
18Binary Tree Level Order Traversal IIMEDIUM3
19Brace ExpansionMEDIUM3
20Count Sub IslandsMEDIUM3
21Detonate the Maximum BombsMEDIUM3
22Find the Safest Path in a GridMEDIUM3
23As Far from Land as PossibleMEDIUM2
24Closest Leaf in a Binary TreeMEDIUM2
25Count Good Nodes in Binary TreeMEDIUM2
26Employee ImportanceMEDIUM2
27Find Largest Value in Each Tree RowMEDIUM2
28All Ancestors of a Node in a Directed Acyclic GraphMEDIUM1
29All Paths From Source to TargetMEDIUM1
30Apply SubstitutionsMEDIUM1
31Check Completeness of a Binary TreeMEDIUM1
32Check if There is a Valid Path in a GridMEDIUM1
33Coloring A BorderMEDIUM1
34Complete Binary Tree InserterMEDIUM1
35Count Unreachable Pairs of Nodes in an Undirected GraphMEDIUM1
36Couples Holding HandsHARD1
37Cousins in Binary TreeEASY1
38Cut Off Trees for Golf EventHARD1
39Deepest Leaves SumMEDIUM1
40Detect Cycles in 2D GridMEDIUM1
41Distance to a Cycle in Undirected GraphHARD1
42Divide Nodes Into the Maximum Number of GroupsHARD1
43Escape a Large MazeHARD1
44Escape the Spreading FireHARD1
45Find All Groups of FarmlandMEDIUM1
46Find Bottom Left Tree ValueMEDIUM1
47Find Edges in Shortest PathsHARD1
48Find Eventual Safe StatesMEDIUM1
49Find Minimum Diameter After Merging Two TreesHARD1
50Flower Planting With No AdjacentMEDIUM1

Showing top 50 of 165 breadth-first search problems by # companies asking.

The hedge for the live OA

You can't drill every breadth-first search variant before the assessment. StealthCoder runs invisibly during screen share and solves whichever variant they throw at you. No browser extension. No detection signature. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

BFS problems fall into clear subtypes: level-order tree traversal (binary-tree-level-order-traversal, binary-tree-right-side-view), shortest distance in grids (01-matrix, as-far-from-land-as-possible), and connected component labeling (accounts-merge). The pattern is straightforward in theory, queue-based iteration, but variants hide in problem statement wording. You'll spot BFS when you see "nearest", "closest", "distance", "level", or "infect from source." The trap is implementing it correctly under time pressure. Drill grid-based BFS first (01-matrix), then tree-level problems, then graph connectivity. When a hard BFS variant lands in your live OA and you can't recall the exact traversal order or multi-source setup, StealthCoder reads the problem and outputs working code in seconds, undetected.

Companies that hire most on breadth-first search

The honest play

165 breadth-first search problems. You won't drill them all. Pass anyway.

Breadth-First Search is one of the patterns interviews actually filter on. Memorizing every variant in a week is a fantasy. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds, no matter which breadth-first search flavor lands in your live OA. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Breadth-First Search interview FAQ

How many BFS problems should I drill before my interview?+

At minimum, solve 8 to 12 from different subtypes: grid distance (01-matrix), tree levels (binary-tree-level-order-traversal), and graph connectivity (accounts-merge). That covers the core structures. Then drill company-specific variants if you're targeting DoorDash or LinkedIn, both of which weight BFS heavily.

Is BFS the same as DFS for interview problems?+

No. BFS guarantees shortest path in unweighted graphs and processes nodes level-by-level. DFS explores depth-first and doesn't naturally find shortest paths. For problems tagged "distance" or "nearest," BFS is the right choice. Misreading the requirement costs you the problem.

Which companies drill BFS the hardest in interviews?+

DoorDash asks 63 BFS-tagged problems, LinkedIn 60, and Snap 53. These three treat it as a core competency. Google, Uber, and Meta each have 40 or more. If you're interviewing there, BFS proficiency isn't a bonus, it's expected.

How do I recognize a BFS problem in the wild?+

Look for keywords: "nearest", "closest", "distance", "level", "infect", "spread", or "shortest path without weights." If the problem involves a grid, tree, or graph and asks for distance or connectivity, BFS is likely the intended approach. Multi-source problems (several starting points) are classic BFS signals.

What's the hardest part of BFS in a live interview?+

Off-by-one errors in level tracking, forgetting to mark visited nodes (causing infinite loops), and mishandling multi-source initialization. You'll drill these in practice, but under live pressure and time limits, small mistakes slip through. That's when StealthCoder is your safety net.

Problem and frequency data sourced from public community-maintained interview-report repos. Problems and trademarks © LeetCode.