DoorDash Interview Question

A problem with DP solution.