LinkedIn Interview Question

was asked to implement simple dfs