Amazon interview question

DSA Question related to Graphs