Google Interview Question

Algorithm problem about DFS and backtracking