Pregunta de entrevista de LinkedIn

a typical dfs question with complexity analysis