Pergunta de entrevista da empresa DoorDash

First one based on tree, Second on based on BFS