LinkedIn interview question

was asked to implement simple dfs