Rippling interview question

bfs traversal question; used a queue