DoorDash Interview Question

DFS Graph Question Question similar to 2 Sum