Question d’entretien chez Amazon

I was asked an easy leetcode q