Amazon interview question

Coding problem on graph data structure.