Cruise Interview Question

They asked a dynamic programming question which was probably leetcode medium-hard