Pergunta de entrevista da empresa Lyft

Tree path question, some graph BFS. Pretty simple stuff.