the basic algorithm. the time complexity is for a graph with nodes and edges.
def dfs(v):
vis[v] = True
for u in adj[v]:
if not vis[u]:
dfs(u)
applications #
related problems #
- CSES 1666 - Building Roads
- CSES 1674 - Subordinates
- Codeforces 580C - Kefa and Park
- Codeforces 727A - Transformation: from A to B
- Codeforces 24A - Ring road
- Codeforces 802J - Send the Fool Further! (easy)
- Codeforces 29C - Mail Stamps
- CSES 1192 - Counting Rooms
- Codeforces 813C - The Tag Game
- Codeforces 378C - Maze