LeetCodechevron_rightCategorieschevron_rightbreadth first search
arrow_outward

breadth first search

197 problems
Easy: 19Medium: 122Hard: 56

breadth first search is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.

Interview Signal

Frequently tests problem modeling, edge handling, and verbal clarity.

Common Pitfall

Template-only answers break under follow-up questioning.

Practice Strategy

Practice in 3-5 problem rounds and always review complexity alternatives.

Recommended Progression

#TitleDifficulty
100

Same Tree

Check whether two binary trees are identical by comparing structure and node values using DFS or BFS traversal strategie…

Easy
101

Symmetric Tree

Determine if a binary tree is symmetric by comparing left and right subtrees using DFS or BFS traversal techniques effic…

Easy
102

Binary Tree Level Order Traversal

Perform a level order traversal on a binary tree using BFS to return node values level by level.

Medium
103

Binary Tree Zigzag Level Order Traversal

Traverse a binary tree in zigzag level order, alternating directions at each depth using BFS and state tracking techniqu…

Medium
104

Maximum Depth of Binary Tree

Find the maximum depth of a binary tree using traversal techniques to track the longest path from root to leaf.

Easy
107

Binary Tree Level Order Traversal II

Return a bottom-up level order traversal of a binary tree, processing nodes left to right while tracking each level accu…

Medium
111

Minimum Depth of Binary Tree

Find the minimum depth of a binary tree, which is the shortest path from the root node to the nearest leaf node.

Easy
112

Path Sum

Determine if a binary tree has a root-to-leaf path where the sum of node values equals a given target sum, using DFS or …

Easy
116

Populating Next Right Pointers in Each Node

Connect each node across every level by reusing established next links to traverse a perfect binary tree without extra q…

Medium
117

Populating Next Right Pointers in Each Node II

Populate each next pointer in a binary tree to its immediate right node, handling nulls and uneven levels efficiently us…

Medium
126

Word Ladder II

Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …

Hard
127

Word Ladder

Find the shortest transformation sequence from a start word to an end word, with each word in the sequence differing by …

Hard
130

Surrounded Regions

Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.

Medium
133

Clone Graph

Clone Graph involves cloning a graph using DFS, focusing on graph traversal and neighbor management using hash tables.

Medium
199

Binary Tree Right Side View

The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…

Medium
200

Number of Islands

Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…

Medium
207

Course Schedule

Determine if all courses can be completed by analyzing prerequisite dependencies using indegree tracking and topological…

Medium
210

Course Schedule II

Solve the 'Course Schedule II' problem using graph indegree and topological ordering, utilizing DFS or BFS to find the c…

Medium
226

Invert Binary Tree

Invert Binary Tree swaps every node's left and right children using tree traversal, with recursive DFS or iterative BFS …

Easy
279

Perfect Squares

Perfect Squares asks for the least number of perfect squares summing to a given integer n using dynamic programming or B…

Medium
297

Serialize and Deserialize Binary Tree

This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…

Hard
301

Remove Invalid Parentheses

Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…

Hard
310

Minimum Height Trees

Identify all roots of a tree that produce minimum height using graph indegree analysis and topological trimming.

Medium
322

Coin Change

Find the minimum number of coins needed to reach a target amount using dynamic programming state transitions efficiently…

Medium
329

Longest Increasing Path in a Matrix

Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.

Hard
365

Water and Jug Problem

Determine if two jugs with given capacities can measure an exact target amount using math and DFS strategies efficiently…

Medium
399

Evaluate Division

Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.

Medium
404

Sum of Left Leaves

Compute the total of all left leaves in a binary tree using precise traversal and state tracking techniques for correctn…

Easy
407

Trapping Rain Water II

Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.

Hard
417

Pacific Atlantic Water Flow

Find all cells on an island where water can flow to both the Pacific and Atlantic oceans using DFS or BFS.

Medium
429

N-ary Tree Level Order Traversal

Perform a level order traversal on an n-ary tree, capturing nodes by depth using breadth-first search with careful state…

Medium
433

Minimum Genetic Mutation

Determine the minimum number of single-character gene mutations to reach the target gene using BFS and a hash table look…

Medium
449

Serialize and Deserialize BST

Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.

Medium
463

Island Perimeter

Determine the perimeter of an island in a grid of land and water cells using DFS or BFS.

Easy
488

Zuma Game

The Zuma Game involves clearing balls from the board using a limited hand, applying dynamic programming and state transi…

Hard
513

Find Bottom Left Tree Value

Find the leftmost value in the last row of a binary tree using efficient traversal strategies.

Medium
514

Freedom Trail

Determine the minimum rotations and button presses to spell a keyword on a circular dial using state transition dynamic …

Hard
515

Find Largest Value in Each Tree Row

Find the largest value in each row of a binary tree using depth-first or breadth-first search techniques.

Medium
529

Minesweeper

Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…

Medium
530

Minimum Absolute Difference in BST

Find the minimum absolute difference between values of any two nodes in a BST using tree traversal and careful state tra…

Easy
542

01 Matrix

The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…

Medium
547

Number of Provinces

Solve Number of Provinces by scanning the adjacency matrix and launching DFS once per unvisited city component.

Medium
559

Maximum Depth of N-ary Tree

Find the maximum depth of an N-ary tree, leveraging tree traversal techniques and state tracking.

Easy
617

Merge Two Binary Trees

Merge Two Binary Trees requires combining nodes by summing overlapping values while preserving non-null nodes from eithe…

Easy
623

Add One Row to Tree

The problem requires adding a row of nodes to a binary tree at a specified depth.

Medium
637

Average of Levels in Binary Tree

Calculate the average value of nodes on each level of a binary tree using traversal and state tracking.

Easy
653

Two Sum IV - Input is a BST

Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…

Easy
655

Print Binary Tree

Print Binary Tree requires arranging a binary tree into a visually structured matrix using precise traversal and positio…

Medium
662

Maximum Width of Binary Tree

Determine the maximum width of a binary tree by calculating the width of each level and considering the positions of the…

Medium
672

Bulb Switcher II

Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.

Medium
675

Cut Off Trees for Golf Event

Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…

Hard
684

Redundant Connection

Identify and remove the redundant edge that causes a cycle in a graph starting as a tree.

Medium
685

Redundant Connection II

Find and remove the redundant connection in a directed graph that was originally a rooted tree.

Hard
690

Employee Importance

Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…

Medium
695

Max Area of Island

Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.

Medium
721

Accounts Merge

Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…

Medium
733

Flood Fill

Flood Fill is an array and DFS problem where you change connected pixels to a target color efficiently using recursion o…

Easy
743

Network Delay Time

Find the minimum time for a signal to travel to all nodes in a directed graph or determine if it's impossible.

Medium
749

Contain Virus

Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…

Hard
752

Open the Lock

Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.

Medium
756

Pyramid Transition Matrix

The Pyramid Transition Matrix problem requires determining whether a pyramid can be formed with given blocks and valid p…

Medium
765

Couples Holding Hands

This problem requires arranging couples sitting apart in a row with the minimum number of swaps using graph traversal an…

Hard
773

Sliding Puzzle

Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …

Hard
778

Swim in Rising Water

Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.

Hard
783

Minimum Distance Between BST Nodes

Find the minimum difference between values of two different nodes in a Binary Search Tree using tree traversal and state…

Easy
785

Is Graph Bipartite?

Determine whether an undirected graph can be split into two independent sets using DFS, BFS, or Union Find patterns.

Medium
787

Cheapest Flights Within K Stops

Find the cheapest flight from a source to a destination with at most K stops using graph traversal techniques efficientl…

Medium
797

All Paths From Source to Target

Find all paths in a directed acyclic graph (DAG) from source to target using depth-first search and backtracking.

Medium
802

Find Eventual Safe States

Solve the problem of finding eventual safe states in a directed graph using depth-first search and topological sorting.

Medium
815

Bus Routes

Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.

Hard
827

Making A Large Island

Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…

Hard
839

Similar String Groups

Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…

Hard
841

Keys and Rooms

Determine if all rooms can be visited given keys distributed across a set of interconnected locked rooms using graph tra…

Medium
847

Shortest Path Visiting All Nodes

Solve the Shortest Path Visiting All Nodes problem by exploring dynamic programming, bit manipulation, and breadth-first…

Hard
854

K-Similar Strings

K-Similar Strings involves finding the minimal number of swaps to transform one string into another through character sw…

Hard
863

All Nodes Distance K in Binary Tree

Find all nodes at distance K from a target node in a binary tree using various tree traversal techniques.

Medium
864

Shortest Path to Get All Keys

Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.

Hard
865

Smallest Subtree with all the Deepest Nodes

Find the smallest subtree that contains all the deepest nodes in a binary tree.

Medium
886

Possible Bipartition

Determine if a group of n people with mutual dislikes can be split into two non-conflicting groups using graph traversal…

Medium
909

Snakes and Ladders

Solve the Snakes and Ladders problem using a BFS strategy to efficiently navigate the board and reach the final square.

Medium
919

Complete Binary Tree Inserter

Implement a data structure to insert nodes into a complete binary tree while preserving its completeness efficiently.

Medium
924

Minimize Malware Spread

Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.

Hard
928

Minimize Malware Spread II

Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.

Hard
934

Shortest Bridge

Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.

Medium
958

Check Completeness of a Binary Tree

Determine if a binary tree is complete by verifying its node structure and leftmost placement in the last level.

Medium
959

Regions Cut By Slashes

Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.

Medium
965

Univalued Binary Tree

Determine if a binary tree is uni-valued using traversal and state tracking techniques.

Easy
967

Numbers With Same Consecutive Differences

Generate all n-digit numbers where consecutive digits differ by k using efficient backtracking and BFS techniques.

Medium
987

Vertical Order Traversal of a Binary Tree

Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.

Hard
993

Cousins in Binary Tree

Determine if two nodes in a binary tree are cousins by leveraging binary-tree traversal and state tracking.

Easy
994

Rotting Oranges

Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.

Medium
1020

Number of Enclaves

This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…

Medium
1034

Coloring A Border

Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …

Medium
1036

Escape a Large Maze

The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…

Hard
1042

Flower Planting With No Adjacent

In this problem, you are tasked with planting flowers in gardens with specific constraints based on graph traversal prin…

Medium
1091

Shortest Path in Binary Matrix

Find the shortest clear path in a binary matrix using BFS, carefully handling obstacles and diagonal movements for effic…

Medium
1096

Brace Expansion II

Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…

Hard
1123

Lowest Common Ancestor of Deepest Leaves

Find the lowest common ancestor of the deepest leaves in a binary tree using efficient traversal and state tracking tech…

Medium
1129

Shortest Path with Alternating Colors

Solve the shortest path problem with alternating edge colors using graph traversal and BFS.

Medium
1161

Maximum Level Sum of a Binary Tree

Find the level of a binary tree where the sum of its nodes is maximal, with an emphasis on binary-tree traversal.

Medium
1162

As Far from Land as Possible

Find the farthest water cell from land in a grid and return the Manhattan distance using state transition dynamic progra…

Medium
1202

Smallest String With Swaps

Find the lexicographically smallest string by swapping characters in given pairs of indices.

Medium
1203

Sort Items by Groups Respecting Dependencies

Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…

Hard
1210

Minimum Moves to Reach Target with Rotations

Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.

Hard
1254

Number of Closed Islands

Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.

Medium
1261

Find Elements in a Contaminated Binary Tree

Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…

Medium
1263

Minimum Moves to Move a Box to Their Target Location

Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…

Hard
1267

Count Servers that Communicate

Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…

Medium
1284

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…

Hard
1293

Shortest Path in a Grid with Obstacles Elimination

Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.

Hard
1298

Maximum Candies You Can Get from Boxes

Collect maximum candies from boxes by exploring initially available boxes and using keys to unlock additional ones effic…

Hard
1302

Deepest Leaves Sum

Find the sum of the deepest leaves in a binary tree by using tree traversal and state tracking techniques.

Medium
1306

Jump Game III

Jump Game III challenges you to determine if you can reach any zero in an array using jumps defined by array values, tes…

Medium
1311

Get Watched Videos by Your Friends

Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.

Medium
1315

Sum of Nodes with Even-Valued Grandparent

This problem involves calculating the sum of nodes with an even-valued grandparent in a binary tree.

Medium
1319

Number of Operations to Make Network Connected

Determine the minimum number of operations required to connect all computers in a network with a limited number of cable…

Medium
1345

Jump Game IV

Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…

Hard
1361

Validate Binary Tree Nodes

Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.

Medium
1368

Minimum Cost to Make at Least One Valid Path in a Grid

Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.

Hard
1376

Time Needed to Inform All Employees

Calculate the time needed for the head of a company to inform all employees using tree traversal techniques.

Medium
1377

Frog Position After T Seconds

The problem asks for the probability that a frog reaches a target vertex after t seconds in a tree graph.

Hard
1379

Find a Corresponding Node of a Binary Tree in a Clone of That Tree

Find the corresponding node in a cloned binary tree using binary-tree traversal and state tracking.

Easy
1391

Check if There is a Valid Path in a Grid

Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.

Medium
1443

Minimum Time to Collect All Apples in a Tree

Minimize the time spent to collect all apples in a tree, considering traversal and state tracking with binary tree techn…

Medium
1448

Count Good Nodes in Binary Tree

Count Good Nodes in Binary Tree identifies nodes exceeding all previous values along their path using DFS traversal tech…

Medium
1457

Pseudo-Palindromic Paths in a Binary Tree

Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.

Medium
1462

Course Schedule IV

Determine if one course is a prerequisite of another using graph indegree tracking and topological ordering efficiently.

Medium
1466

Reorder Routes to Make All Paths Lead to the City Zero

Reorder Routes to Make All Paths Lead to the City Zero involves reversing the direction of roads in a tree to ensure all…

Medium
1483

Kth Ancestor of a Tree Node

Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.

Hard
1519

Number of Nodes in the Sub-Tree With the Same Label

Compute the number of nodes in each subtree sharing the same label using DFS with hash table aggregation efficiently.

Medium
1559

Detect Cycles in 2D Grid

Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.

Medium
1568

Minimum Number of Days to Disconnect Island

Find the minimum number of days to disconnect an island in a grid using depth-first search.

Hard
1609

Even Odd Tree

Determine if a binary tree meets Even-Odd rules by checking value parity and strict ordering at each level efficiently.

Medium
1625

Lexicographically Smallest String After Applying Operations

Optimize a string through rotations and additions to get the lexicographically smallest possible result using string man…

Medium
1631

Path With Minimum Effort

Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…

Medium
1654

Minimum Jumps to Reach Home

Find the minimum number of jumps needed to reach a target position while avoiding forbidden positions.

Medium
1765

Map of Highest Peak

Solve the Map of Highest Peak problem using breadth-first search to assign heights based on proximity to water cells.

Medium
1905

Count Sub Islands

Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…

Medium
1926

Nearest Exit from Entrance in Maze

Find the shortest path from the maze entrance to the nearest border exit using BFS over a 2D array matrix efficiently.

Medium
1970

Last Day Where You Can Still Cross

Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.

Hard
1971

Find if Path Exists in Graph

Determine if a valid path exists between two vertices in a bi-directional graph using traversal techniques.

Easy
1992

Find All Groups of Farmland

Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.

Medium
1993

Operations on Tree

Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.

Medium
2039

The Time When the Network Becomes Idle

Calculate the time when the network becomes idle, factoring in message resending and the BFS traversal method.

Medium
2045

Second Minimum Time to Reach Destination

Find the second minimum time to reach a destination using BFS while accounting for traffic signal delays in a graph trav…

Hard
2059

Minimum Operations to Convert Number

Determine the minimum operations needed to convert a number using array elements with addition, subtraction, or XOR oper…

Medium
2092

Find All People With Secret

Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…

Hard
2101

Detonate the Maximum Bombs

Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …

Medium
2146

K Highest Ranked Items Within a Price Range

Use BFS to rank reachable shop items by distance, price, row, and column, then return the best k coordinates.

Medium
2192

All Ancestors of a Node in a Directed Acyclic Graph

Solve the All Ancestors of a Node in a Directed Acyclic Graph problem using graph traversal techniques like BFS, DFS, an…

Medium
2258

Escape the Spreading Fire

Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…

Hard
2290

Minimum Obstacle Removal to Reach Corner

Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.

Hard
2316

Count Unreachable Pairs of Nodes in an Undirected Graph

Calculate the total number of node pairs in an undirected graph that cannot reach each other using DFS, BFS, or Union Fi…

Medium
2328

Number of Increasing Paths in a Grid

Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…

Hard
2360

Longest Cycle in a Graph

The problem asks to find the longest cycle in a directed graph with specific edge constraints.

Hard
2368

Reachable Nodes With Restrictions

In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…

Medium
2385

Amount of Time for Binary Tree to Be Infected

The problem asks to calculate the number of minutes for an infection to spread across all nodes in a binary tree startin…

Medium
2415

Reverse Odd Levels of Binary Tree

Reverse the node values at each odd level in a perfect binary tree, preserving the even levels.

Medium
2458

Height of Binary Tree After Subtree Removal Queries

Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…

Hard
2467

Most Profitable Path in a Tree

Solve the 'Most Profitable Path in a Tree' problem using graph traversal and depth-first search techniques to maximize A…

Medium
2471

Minimum Number of Operations to Sort a Binary Tree by Level

Determine the minimum number of swaps to sort each level of a binary tree using level-wise traversal efficiently.

Medium
2477

Minimum Fuel Cost to Report to the Capital

Calculate the minimum fuel needed for all city representatives to reach the capital using DFS on a tree graph efficientl…

Medium
2492

Minimum Score of a Path Between Two Cities

Find the minimum distance in a path connecting two cities using graph traversal strategies efficiently.

Medium
2493

Divide Nodes Into the Maximum Number of Groups

Determine the maximum number of groups nodes can form in a graph using depth-first traversal without violating edge conn…

Hard
2503

Maximum Number of Points From Grid Queries

Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.

Hard
2556

Disconnect Path in a Binary Matrix by at Most One Flip

Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…

Medium
2577

Minimum Time to Visit a Cell In a Grid

Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…

Hard
2583

Kth Largest Sum in a Binary Tree

Find the kth largest level sum in a binary tree using level-order traversal and sorting.

Medium
2596

Check Knight Tour Configuration

Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.

Medium
2608

Shortest Cycle in a Graph

Find the shortest cycle in a bi-directional graph using BFS for optimal traversal.

Hard
2612

Minimum Reverse Operations

Find the minimum number of operations to move a 1 in an array from a given start position to other positions, considerin…

Hard
2617

Minimum Number of Visited Cells in a Grid

Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…

Hard
2641

Cousins in Binary Tree II

Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.

Medium
2658

Maximum Number of Fish in a Grid

Maximize the number of fish that can be caught by performing DFS on an optimal starting point in a grid.

Medium
2685

Count the Number of Complete Components

Determine the number of complete connected components in an undirected graph using efficient traversal techniques and gr…

Medium
2812

Find the Safest Path in a Grid

Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.

Medium
2850

Minimum Moves to Spread Stones Over Grid

Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…

Medium
2858

Minimum Edge Reversals So Every Node Is Reachable

This problem requires solving a graph traversal with edge reversals to ensure every node is reachable in a tree-like str…

Hard
2998

Minimum Number of Operations to Make X and Y Equal

Determine the minimum operations to make two integers equal using increment, decrement, and division efficiently with DP…

Medium
3015

Count the Number of Houses at a Certain Distance I

Determine the number of house pairs at each street distance using graph traversal and breadth-first search efficiently.

Medium
3123

Find Edges in Shortest Paths

Use two Dijkstra runs to mark exactly which edges can appear on at least one shortest path from 0 to n - 1.

Hard
3203

Find Minimum Diameter After Merging Two Trees

Calculate the minimum diameter after merging two trees by strategically connecting nodes to minimize the longest path in…

Hard
3235

Check if the Rectangle Corner Is Reachable

Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.

Hard
3243

Shortest Distance After Road Addition Queries I

Solve shortest paths dynamically in a growing graph using BFS, updating distances efficiently after each road addition q…

Medium
3283

Maximum Number of Moves to Kill All Pawns

Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…

Hard
3286

Find a Safe Walk Through a Grid

Determine if you can safely traverse a binary grid from top-left to bottom-right using limited health points.

Medium
3310

Remove Methods From Project

Remove suspicious methods in a project that are invoked directly or indirectly from a buggy method using graph traversal…

Medium
3372

Maximize the Number of Target Nodes After Connecting Trees I

Maximize the number of target nodes after connecting two trees using binary tree traversal and state tracking.

Medium
3373

Maximize the Number of Target Nodes After Connecting Trees II

Maximize the number of target nodes after connecting two trees by analyzing their structure and target relationships.

Hard
3387

Maximize Amount After Two Days of Conversions

Compute the maximum currency amount after two days using graph traversal and depth-first search for optimal conversions.

Medium
3419

Minimize the Maximum Edge Weight of Graph

Minimize the maximum edge weight in a graph after removing certain edges while ensuring node reachability.

Medium
3493

Properties Graph

Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…

Medium
3528

Unit Conversion I

Solve the unit conversion problem by using graph traversal to compute equivalent unit amounts.

Medium
3552

Grid Teleportation Traversal

Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.

Medium
3568

Minimum Moves to Clean the Classroom

Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.

Medium
3607

Power Grid Maintenance

Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…

Medium
3619

Count Islands With Total Value Divisible by K

Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.

Medium

Related Patterns

Breadth-First Search LeetCode Problems: 197 Solutions