Question d’entretien chez Amazon

Leetcode question with two parts