Google interview question

BFS Question