Amazon interview question

question on multisource bfs