Pregunta de entrevista de Amazon

BFS search tree algorithm with conditions