Amazon Interview Question

It was a tree problem that could be solved with simple DFS .