Pregunta de entrevista de Amazon

I had a dynamic programming question