DoorDash Interview Question

dfs problem of printing the path