6sense interview question

DFS, Trees