Pergunta de entrevista da empresa Amazon

I got questions from Stack, dynamic programming