Amazon interview question

Breadth First Search