Street Simplified interview question

a simple BFS problem with graphs