Amazon interview question

MST question with dp on a graph