Toast Inc Interview Question

Technical question involving BFS/DFS