Amazon Interview Question

MST question with dp on a graph