Queue / BFS Pattern

Explore level by level for shortest paths and multi-source floods.

#Title
102Binary Tree Level Order Traversal
103Binary Tree Zigzag Level Order Traversal
107Binary Tree Level Order Traversal II
117Populating Next Right Pointers in Each Node II
127Word Ladder
130Surrounded Regions
133Clone Graph
200Number of Islands
207Course Schedule
210Course Schedule II
239Sliding Window Maximum
261Graph Valid Tree
269Alien Dictionary
281Zigzag Iterator
286Walls and Gates
310Minimum Height Trees
314Binary Tree Vertical Order Traversal
317Shortest Distance from All Buildings
346Moving Average from Data Stream
399Evaluate Division
433Minimum Genetic Mutation
490The Maze
499The Maze III
505The Maze II
513Find Bottom Left Tree Value
582Kill Process
690Employee Importance
742Closest Leaf in a Binary Tree
743Network Delay Time
752Open the Lock
787Cheapest Flights Within K Stops
815Bus Routes
847Shortest Path Visiting All Nodes
854K-Similar Strings
882Reachable Nodes In Subdivided Graph
886Possible Bipartition
933Number of Recent Calls
934Shortest Bridge
958Check Completeness of a Binary Tree
967Numbers With Same Consecutive Differences
994Rotting Oranges
1034Coloring A Border
1036Escape a Large Maze
1091Shortest Path in Binary Matrix
1129Shortest Path with Alternating Colors
1136Parallel Courses
1162As Far from Land as Possible
1210Minimum Moves to Reach Target with Rotations
1245Tree Diameter
1284Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
1291Sequential Digits
1298Maximum Candies You Can Get from Boxes
1302Deepest Leaves Sum
1306Jump Game III
1311Get Watched Videos by Your Friends
1345Jump Game IV
1377Frog Position After T Seconds
1424Diagonal Traverse II
1430Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree
1438Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
1499Max Value of Equation
1514Path with Maximum Probability
1559Detect Cycles in 2D Grid
1602Find Nearest Right Node in Binary Tree
1609Even Odd Tree
1625Lexicographically Smallest String After Applying Operations
1631Path With Minimum Effort
1654Minimum Jumps to Reach Home
1660Correct a Binary Tree
1730Shortest Path to Get Food
1765Map of Highest Peak
1778Shortest Path in a Hidden Grid
1871Jump Game VII
1926Nearest Exit from Entrance in Maze
1928Minimum Cost to Reach Destination in Time
1932Merge BSTs to Create Single BST
2039The Time When the Network Becomes Idle
2045Second Minimum Time to Reach Destination
2050Parallel Courses III
2059Minimum Operations to Convert Number
2092Find All People With Secret
2115Find All Possible Recipes from Given Supplies
2146K Highest Ranked Items Within a Price Range
2246Longest Path With Different Adjacent Characters
2247Maximum Cost of Trip With K Highways
2258Escape the Spreading Fire
2277Closest Node to Path in Tree
2316Count Unreachable Pairs of Nodes in an Undirected Graph
2368Reachable Nodes With Restrictions
2385Amount of Time for Binary Tree to Be Infected
2386Find the K-Sum of an Array
2415Reverse Odd Levels of Binary Tree
2440Create Components With Same Value
2445Number of Nodes With Value One
2471Minimum Number of Operations to Sort a Binary Tree by Level
2492Minimum Score of a Path Between Two Cities
2493Divide Nodes Into the Maximum Number of Groups
2503Maximum Number of Points From Grid Queries
2583Kth Largest Sum in a Binary Tree
2603Collect Coins in a Tree
2608Shortest Cycle in a Graph
2612Minimum Reverse Operations
2617Minimum Number of Visited Cells in a Grid
2641Cousins in Binary Tree II
2658Maximum Number of Fish in a Grid
2684Maximum Number of Moves in a Grid
2685Count the Number of Complete Components
2709Greatest Common Divisor Traversal
2773Height of Special Binary Tree
2812Find the Safest Path in a Grid
2814Minimum Time Takes to Reach Destination Without Drowning
2852Sum of Remoteness of All Cells
2872Maximum Number of K-Divisible Components
2998Minimum Number of Operations to Make X and Y Equal
3067Count Pairs of Connectable Servers in a Weighted Tree Network
3141Maximum Hamming Distances
3157Find the Level of Tree with Minimum Sum
3203Find Minimum Diameter After Merging Two Trees
3211Generate Binary Strings Without Adjacent Zeros
3235Check if the Rectangle Corner Is Reachable
3236CEO Subordinate Hierarchy
3241Time Taken to Mark All Nodes
3243Shortest Distance After Road Addition Queries I
3265Count Almost Equal Pairs I
3267Count Almost Equal Pairs II
3283Maximum Number of Moves to Kill All Pawns
3286Find a Safe Walk Through a Grid
3310Remove Methods From Project
3311Construct 2D Grid Matching Graph Layout
3313Find the Last Marked Nodes in Tree
3372Maximize the Number of Target Nodes After Connecting Trees I
3373Maximize the Number of Target Nodes After Connecting Trees II
3387Maximize Amount After Two Days of Conversions
3419Minimize the Maximum Edge Weight of Graph
3482Analyze Organization Hierarchy
3493Properties Graph
3528Unit Conversion I
3535Unit Conversion II
3547Maximum Sum of Edge Values in a Graph
3552Grid Teleportation Traversal
3558Number of Ways to Assign Edge Weights I
3568Minimum Moves to Clean the Classroom
3619Count Islands With Total Value Divisible by K
3629Minimum Jumps to Reach End via Prime Teleportation
3690Split and Merge Array Transformation
3695Maximize Alternating Sum Using Swaps
3710Maximum Partition Factor
3772Maximum Subgraph Score in a Tree
3786Total Sum of Interaction Cost in Tree Groups
3787Find Diameter Endpoints of a Tree
3807Minimum Cost to Repair Edges to Traverse a Graph
3820Pythagorean Distance Nodes in a Tree
3831Median of a Binary Search Tree Level
3869Count Fancy Numbers in a Range
3877Minimum Removals to Achieve Target XOR
3879Maximum Distinct Path Sum in a Binary Tree
3902Zigzag Level Sum of Binary Tree
3905Multi Source Flood Fill
3923Minimum Generations to Target Point
3991Sort Array Using Prefix Reversals