Meta interview question

DFS implementation