Talentd
FleetCode
Make and follow sheets.Sign in

Breadth-First Search Problems (257)

Problems tagged with Breadth-First Search. Start with the easy ones, then move to medium and hard.

20 Easy166 Medium71 Hard

Learn these first

1
Graph

BFS is primarily used to traverse graphs. Understanding graph representations such as adjacency lists and adjacency matrices helps you implement BFS efficiently.

2
Queue

BFS relies on a queue to process nodes in first-in-first-out order, enabling level-by-level traversal across graphs or trees.

3
Matrix

Grid and matrix problems often model cells as graph nodes. BFS is commonly used to explore neighbors in four or eight directions.

4
Binary Tree

Many BFS interview problems involve level-order traversal of binary trees, where nodes are processed layer by layer using a queue.

5
Depth-First Search

Learning DFS alongside BFS helps you understand when to use each traversal strategy and how they differ in recursion, stack usage, and traversal order.

TitleSolutionAcceptDifficultyTopics
126. Word Ladder IIVideo
Solution27.7%Hard
127. Word LadderVideo
Solution46.3%Hard
Breadth-First Search, Hash Table +1· 41 companies
269. Alien DictionaryVideoPremium
Solution37.1%Hard
Array, Breadth-First Search +4· 18 companies
Solution44.9%Hard
Array, Breadth-First Search +1· 15 companies
Solution64.0%Hard
Array, Breadth-First Search +2· 14 companies
488. Zuma GameVideo
Solution29.4%Hard
499. The Maze IIIVideoPremium
Solution52.3%Hard
Array, Breadth-First Search +6· 1 company
749. Contain VirusVideo
Solution56.5%Hard
Array, Breadth-First Search +3· 3 companies
773. Sliding PuzzleVideo
Solution74.3%Hard
Array, Backtracking +4· 7 companies
Solution68.3%Hard
Array, Binary Search +5· 8 companies
815. Bus RoutesVideo
Solution47.3%Hard
Array, Breadth-First Search +1· 18 companies
Solution57.0%Hard
Array, Breadth-First Search +3· 16 companies
Solution56.7%Hard
Array, Breadth-First Search +4· 5 companies
Solution41.3%Hard
Solution43.6%Hard
Array, Breadth-First Search +4· 10 companies
Solution37.0%Hard
Array, Breadth-First Search +2· 4 companies
1345. Jump Game IVVideo
Solution50.9%Hard
Array, Breadth-First Search +1· 4 companies
Solution39.7%Hard
Array, Binary Search +2· 4 companies
–62.1%Hard
Array, Breadth-First Search +2· 1 company
Showing 1–50 of 71

More about Breadth-First Search

Breadth-First Search (BFS) is a fundamental graph traversal algorithm used to explore nodes level by level. Starting from a source node, BFS visits all its immediate neighbors before moving to the next layer of nodes. This level-order exploration makes BFS one of the most important techniques for solving shortest-path and traversal problems in unweighted graphs. The algorithm typically relies on a Queue to maintain the order of exploration.

In coding interviews, BFS appears frequently in problems involving graphs, grids, and trees. Many interview questions about Graph traversal, shortest paths, or level-order processing rely directly on BFS. For example, BFS is commonly used to find the minimum number of steps between nodes, perform level-order traversal in a Binary Tree, or explore connected components in grid-based problems such as islands in a Matrix. Because BFS guarantees the shortest path in unweighted graphs, it is also a key building block for more advanced algorithms like those in Shortest Path problems.

Several common interview patterns are built around BFS. These include multi-source BFS (starting from multiple nodes simultaneously), level-by-level traversal, shortest path in an unweighted graph, and BFS on grids with directional movement. Many problems also combine BFS with data structures like hash sets for visited tracking, or with graph representations such as adjacency lists.

You should choose BFS when the problem asks for the minimum number of steps, level-based traversal, or exploring neighbors in expanding layers. It is especially effective for unweighted graphs, grid navigation, and tree level traversal. By practicing BFS problems consistently, you will develop strong intuition for graph exploration patterns and significantly improve your performance in technical interviews.

Breadth-First Search: common questions

When should I use BFS instead of DFS?

Use BFS when the problem requires the minimum number of steps, shortest path in an unweighted graph, or level-by-level traversal. DFS is often better for exploring all possible paths or recursion-heavy problems, while BFS guarantees the shortest path in terms of edges.

What are common Breadth-First Search patterns?

Common BFS patterns include level-order traversal, shortest path in unweighted graphs, multi-source BFS, BFS on grids, and state-space search. These patterns frequently appear in graph, matrix, and tree problems in coding interviews.

What is the best way to learn Breadth-First Search?

Start by understanding the BFS algorithm and its queue-based implementation. Then practice core patterns such as level-order traversal, multi-source BFS, and shortest path in unweighted graphs.

Is Breadth-First Search important for FAANG interviews?

Yes, BFS is extremely important for FAANG and top tech interviews. Many graph, tree, and grid problems rely on BFS for shortest path discovery and level-based traversal. Interviewers frequently test BFS alongside DFS and graph fundamentals.

What are the best Breadth-First Search problems for interviews?

The best BFS interview problems usually involve shortest paths in unweighted graphs, level-order traversal of trees, and grid exploration such as island counting. Classic examples include Word Ladder, Rotting Oranges, and Binary Tree Level Order Traversal.