Pregunta de entrevista de Snap

leetcode question, dynamic programming question