DoorDash Interview Question

About dp and the graph