Amazon interview question

Trees and graphs+ Dynamic Programming