Pregunta de entrevista de Cruise

Leetcode medium level dynamic programing question