Question d’entretien chez Amazon

one hard question from Dynamic programming