Question d’entretien chez DoorDash

First one based on tree, Second on based on BFS