圖遍歷・連通分量 Graph DFS / Connectivity
51 題(3 題以此為主技法)
🎯 何時用
數島嶼/連通塊、判環、填充、複製圖。
🧩 模板心法
DFS/BFS 走訪並標記 visited;網格把每格當節點、四方向擴張。
Easy 2 題
Medium 39 題
- #1958Check if Move Is Legal
- #2477Minimum Fuel Cost to Report to the Capital
- #133Clone Graph
- #200Number of Islands
- #207Course Schedule
- #261Graph Valid Tree
- #323Number of Connected Components in an Undirected Graph
- #417Pacific Atlantic Water Flow
- #130Surrounded Regions
- #210Course Schedule II
- #684Redundant Connection
- #695Max Area of Island
- #721Accounts Merge
- #743Network Delay Time
- #787Cheapest Flights Within K Stops
- #994Rotting Oranges
- #1584Min Cost to Connect All Points
- #286Walls and Gates
- #399Evaluate Division
- #752Open The Lock
- #785Is Graph Bipartite?
- #802Find Eventual Safe States
- #909Snakes And Ladders
- #934Shortest Bridge
- #1020Number of Enclaves
- #1091Shortest Path in Binary Matrix
- #1129Shortest Path with Alternating Colors
- #1162As Far from Land as Possible
- #1254Number of Closed Islands
- #1443Minimum Time to Collect All Apples in a Tree
- #1462Course Schedule IV
- #1466Reorder Routes to Make All Paths Lead to The City Zero
- #1514Path with Maximum Probability
- #1557Minimum Number of Vertices to Reach all Nodes
- #1631Path with Minimum Effort
- #1905Count Sub Islands
- #2101Detonate the Maximum Bombs
- #2359Find Closest Node to Given Two Nodes
- #2492Minimum Score of a Path Between Two Cities
Hard 10 題
- #269Alien Dictionary
- #127Word Ladder
- #332Reconstruct Itinerary
- #126Word Ladder II
- #778Swim in Rising Water
- #1489Find Critical and Pseudo Critical Edges in Minimum Spanning Tree
- #1553Minimum Number of Days to Eat N Oranges
- #1579Remove Max Number of Edges to Keep Graph Fully Traversable
- #1857Largest Color Value in a Directed Graph
- #2421Number of Good Paths