Question d’entretien chez Amazon

Leetcode question is medium difficulty level