S
All challenges
Practice
Home
Blog
Practice
Examples
Feedback
DFS Traversal
00:00
Start
00:00
Sign in
Problem
Hints
3
Solution
History
Easy
Graph
DFS
Stack
Recursion
TCS
Wipro
Amazon
Implement DFS traversal of a graph given as adjacency list starting from a source vertex.
Examples
Example 1
Input →
graph={0:[1,2],1:[0,3],2:[0]}, start=0
Output →
[0,1,3,2]
Example 2
Input →
linear 0
Output →
1→2→3 → [0,1,2,3]
Example 3
Input →
no edges
Output →
[start]
JavaScript
Python
Java (Coming soon)
C (Coming soon)
C++ (Coming soon)
Reset
Run
Submit
Cases
Results