Question d’entretien chez Amazon

Leetcode medium question (no coding required)