Domanda di colloquio di Amazon

Question with either dynamic programming or one of 15 patterns