Domanda di colloquio di Amazon

I had a dynamic programming problem that was not too hard