Pregunta de entrevista de DoorDash

First one based on tree, Second on based on BFS