Question d’entretien chez Amazon

Leetcode easy-medium question from Tree Stack