Domanda di colloquio di Cruise

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