Pachyderm interview question

DFS and Array Logic leet code