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
841. Keys and RoomsVideo
Solution76.2%Medium
Solution48.0%Medium
Array, Breadth-First Search +1· 12 companies
934. Shortest BridgeVideo
Solution59.9%Medium
Array, Breadth-First Search +2· 16 companies
Solution77.8%Medium
Array, Breadth-First Search +4· 6 companies
994. Rotting OrangesVideo
Solution59.5%Medium
Array, Breadth-First Search +1· 52 companies
Solution72.2%Medium
Array, Breadth-First Search +3· 5 companies
Solution51.8%Medium
Array, Breadth-First Search +2· 3 companies
1087. Brace ExpansionVideoPremium
Solution66.5%Medium
Solution51.8%Medium
Array, Breadth-First Search +1· 15 companies
Solution54.6%Medium
Array, Binary Search +5· 3 companies
Solution52.2%Medium
Array, Breadth-First Search +2· 7 companies
1197. Minimum Knight MovesVideoPremium
Solution41.8%Medium
Breadth-First Search· 13 companies
Solution61.0%Medium
Array, Breadth-First Search +5· 8 companies
1215. Stepping NumbersVideoPremium
Solution48.2%Medium
1236. Web CrawlerVideoPremium
Solution68.8%Medium
1242. Web Crawler MultithreadedVideoPremium
–49.5%Medium
1245. Tree DiameterVideoPremium
Solution61.1%Medium
Solution70.4%Medium
Array, Breadth-First Search +3· 5 companies
1257. Smallest Common RegionVideoPremium
Solution68.6%Medium
Array, Breadth-First Search +4· 1 company
1273. Delete Tree NodesVideoPremium
Solution61.2%Medium
Array, Breadth-First Search +2· 1 company
Solution86.3%Medium
1306. Jump Game IIIVideo
Solution70.1%Medium
Array, Breadth-First Search +1· 3 companies
1490. Clone N-ary TreeVideoPremium
Solution83.2%Medium
Showing 51–100 of 166

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.