Question d’entretien chez Amazon

a medium difficulty leetcode question