Question d’entretien chez Amazon

leetcode looking question but slightly harder