Question d’entretien chez Amazon

Medium-hard leetcode question based on DP