Amazon interview question

Graph, Heap and sorting