Money View interview question

Coding questions on DFS and HashMap