Amazon Interview Question

Trees and graphs+ Dynamic Programming