DoorDash interview question

A problem with DP solution.