Google Interview Question

algorithm problem can be solved with dfs