Indeed interview question

BFS question