Pregunta de entrevista de Google

algorithm problem can be solved with dfs