Pergunta de entrevista da empresa Amazon

I had a dynamic programming question