廣度優先 BFS BFS
51 題(35 題以此為主技法)
🎯 何時用
無權圖最短步數、層序遍歷、多源同時擴散(腐爛橘子)。
🧩 模板心法
佇列逐層擴張、visited 去重;多源就把所有起點先入隊。層數即最短距離。
Easy 5 題
Medium 40 題
- #102Binary Tree Level Order Traversal
- #133Clone Graph
- #322Coin Change
- #417Pacific Atlantic Water Flow
- #199Binary Tree Right Side View
- #695Max Area of Island
- #994Rotting Oranges
- #45Jump Game II
- #103Binary Tree Zigzag Level Order Traversal
- #116Populating Next Right Pointers in Each Node
- #279Perfect Squares
- #286Walls and Gates
- #513Find Bottom Left Tree Value
- #662Maximum Width of Binary Tree
- #752Open The Lock
- #909Snakes And Ladders
- #934Shortest Bridge
- #958Check Completeness of a Binary Tree
- #1020Number of Enclaves
- #1091Shortest Path in Binary Matrix
- #1129Shortest Path with Alternating Colors
- #1162As Far from Land as Possible
- #1254Number of Closed Islands
- #1376Time Needed to Inform All Employees
- #1466Reorder Routes to Make All Paths Lead to The City Zero
- #1871Jump Game VII
- #2101Detonate the Maximum Bombs
- #2359Find Closest Node to Given Two Nodes
- #200Number of Islands
- #207Course Schedule
- #261Graph Valid Tree
- #323Number of Connected Components in an Undirected Graph
- #130Surrounded Regions
- #210Course Schedule II
- #721Accounts Merge
- #399Evaluate Division
- #785Is Graph Bipartite?
- #1462Course Schedule IV
- #1905Count Sub Islands
- #2492Minimum Score of a Path Between Two Cities