J.P. Morgan Interview Question

Pretty entry level question that involved solving a BFS/DFS for the second part.