Pregunta de entrevista de Uber

Search question, breadth first search.