Pergunta de entrevista da empresa Yelp

Pretty straightforward BFS graph question