dsa1 min read
Find if Path Exists in Graph — BFS/Union-Find
Check if a path exists between source and destination in an undirected graph. BFS from source or Union-Find both work in O(V+E).
Read →
1575 articles
Check if a path exists between source and destination in an undirected graph. BFS from source or Union-Find both work in O(V+E).
BFS from entrance in a maze to find nearest exit (border empty cell). Classic BFS shortest path with exit condition.
Minimum dice rolls to reach square n^2. Convert board position to 2D coordinates (Boustrophedon order), BFS on board states.
Minimum turns to reach target combination avoiding deadends. BFS over all 4-digit wheel states with bidirectional BFS optimization.
Check if you can reach a 0 in the array by jumping arr[i] steps left or right. BFS/DFS from start index.