Amazon interview question

Dynamic Programming, Trees and graphs