> For the complete documentation index, see [llms.txt](https://mayanktyagi3111.gitbook.io/interview-prep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs.md).

# Graphs, BFS & DFS

- [BFS](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/bfs.md)
- [DFS](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/dfs.md)
- [Find if there is a path between two vertices in a undirected graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/find-if-there-is-a-path-between-two-vertices-in-a-undirected-graph.md)
- [Clone Graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/clone-graph.md)
- [Valid Path](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/valid-path.md)
- [Check if given undirected graph is connected or not](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/check-if-given-undirected-graph-is-connected-or-not.md)
- [Connected Components in an undirected graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/connected-components-in-an-undirected-graph.md)
- [Number of Islands](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-islands.md)
- [Surrounded Regions](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/surrounded-regions.md)
- [Fox And Two Dots](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/fox-and-two-dots.md)
- [3 Cycle](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/3-cycle.md)
- [Find the shortest path between two vertices in an undirected graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/find-the-shortest-path-between-two-vertices-in-an-undirected-graph.md)
- [Course Schedule](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/course-schedule.md)
- [Word Search](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/word-search.md)
- [MST](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/mst.md)
- [D-Dimensional MST](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/d-dimensional-mst.md)
- [Dijkstra](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/dijkstra.md)
- [Is Graph Bipartite?](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/is-graph-bipartite.md)
- [Redundant Connection](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/redundant-connection.md)
- [Redundant Connection II](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/redundant-connection-ii.md)
- [Word Ladder](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/word-ladder.md)
- [Word Ladder II](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/word-ladder-ii.md)
- [As Far from Land as Possible](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/as-far-from-land-as-possible.md)
- [Commutable Islands](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/commutable-islands.md)
- [Count Servers that Communicate](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/count-servers-that-communicate.md)
- [Strongly Connected Components](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/strongly-connected-components.md)
- [Course Schedule II](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/course-schedule-ii.md)
- [Black Shapes](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/black-shapes.md)
- [Word Search Board](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/word-search-board.md)
- [Word Search II](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/word-search-ii.md)
- [Knight On Chess Board](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/knight-on-chess-board.md)
- [Smallest Multiple With 0 and 1](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/smallest-multiple-with-0-and-1.md)
- [Stepping Numbers](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/stepping-numbers.md)
- [Number of Closed Islands](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-closed-islands.md)
- [Minesweeper](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/minesweeper.md)
- [Shortest Bridge](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/shortest-bridge.md)
- [Friend Circles](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/friend-circles.md)
- [Network Delay Time](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/network-delay-time.md)
- [Number of Enclaves](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-enclaves.md)
- [Most Stones Removed with Same Row or Column](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/most-stones-removed-with-same-row-or-column.md)
- [Time Needed to Inform All Employees](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/time-needed-to-inform-all-employees.md)
- [Open the Lock](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/open-the-lock.md)
- [Critical Connections in a Network](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/critical-connections-in-a-network.md)
- [Articulation Points (or Cut Vertices) in a Graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/articulation-points-or-cut-vertices-in-a-graph.md)
- [Rotting Oranges](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/rotting-oranges.md)
- [Accounts Merge](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/accounts-merge.md)
- [Possible Bipartition](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/possible-bipartition.md)
- [Path with Maximum Gold](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/path-with-maximum-gold.md)
- [Reorder Routes to Make All Paths Lead to the City Zero](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/reorder-routes-to-make-all-paths-lead-to-the-city-zero.md)
- [Course Schedule IV](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/course-schedule-iv.md)
- [Bus Routes](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/bus-routes.md)
- [Minimum cost to connect cities](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/minimum-cost-to-connect-cities.md)
- [Cheapest Flights Within K Stops](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/cheapest-flights-within-k-stops.md)
- [Minimum Height Trees](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/minimum-height-trees.md)
- [Evaluate Division](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/evaluate-division.md)
- [Keys and Rooms](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/keys-and-rooms.md)
- [Find the Town Judge](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/find-the-town-judge.md)
- [Shortest Path with Alternating Colors](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/shortest-path-with-alternating-colors.md)
- [Check if There is a Valid Path in a Grid](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/check-if-there-is-a-valid-path-in-a-grid.md)
- [Reconstruct Itinerary](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/reconstruct-itinerary.md)
- [Snakes and Ladders](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/snakes-and-ladders.md)
- [Shortest Path in Binary Matrix](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/shortest-path-in-binary-matrix.md)
- [01 Matrix](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/01-matrix.md)
- [Pacific Atlantic Water Flow](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/pacific-atlantic-water-flow.md)
- [Coloring A Border](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/coloring-a-border.md)
- [Chef and Reversing](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/chef-and-reversing.md)
- [Optimize Water Distribution in a Village](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/optimize-water-distribution-in-a-village.md)
- [Number of Operations to Make Network Connected](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-operations-to-make-network-connected.md)
- [Mother Vertex](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/mother-vertex.md)
- [Number of Islands II](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-islands-ii.md)
- [Number of Distinct Islands](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-distinct-islands.md)
- [Regions Cut By Slashes](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/regions-cut-by-slashes.md)
- [Satisfiability of Equality Equations](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/satisfiability-of-equality-equations.md)
- [Job Sequencing Problem (Using DSU)](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/job-sequencing-problem-using-dsu.md)
- [Sentence Similarity II](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/sentence-similarity-ii.md)
- [Sort Items by Groups Respecting Dependencies](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/sort-items-by-groups-respecting-dependencies.md)
- [Eulerian path and circuit for undirected graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/eulerian-path-and-circuit-for-undirected-graph.md): Assume connected graph
- [Eulerian path and circuit for directed graph](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/eulerian-path-and-circuit-for-directed-graph.md): Assume SCC
- [Making A Large Island](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/making-a-large-island.md)
- [Shortest Distance from All Buildings](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/number-of-distinct-islands-ii.md)
- [Alphabet Board Path](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/alphabet-board-path.md)
- [Graph Valid Tree](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/graph-valid-tree.md)
- [Alien Dictionary](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/alien-dictionary.md)
- [Similar String Groups](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/similar-string-groups.md)
- [Walls and Gates](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/walls-and-gates.md)
- [K-Similar Strings](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/k-similar-strings.md)
- [Sliding Puzzle](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/sliding-puzzle.md)
- [Minimum number of swaps required to sort an array](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/minimum-number-of-swaps-required-to-sort-an-array.md)
- [Minimize Malware Spread](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/minimize-malware-spread.md)
- [Doctor Strange](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/doctor-strange.md)
- [Castle RUN](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/castle-run.md)
- [Find the Maximum Flow](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/find-the-maximum-flow.md)
- [All Paths from Source Lead to Destination](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/all-paths-from-source-lead-to-destination.md)
- [Jump Game IV](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/jump-game-iv.md)
- [Cut Off Trees for Golf Event](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/cut-off-trees-for-golf-event.md)
- [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.md)
- [Detect Cycles in 2D Grid](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/detect-cycles-in-2d-grid.md)
- [Find Latest Group of Size M](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/find-latest-group-of-size-m.md)
- [Minimum Number of Days to Disconnect Island](https://mayanktyagi3111.gitbook.io/interview-prep/graphs-bfs-and-dfs/minimum-number-of-days-to-disconnect-island.md)
