Question d’entretien chez Amazon

Leetcode question, at least between medium and hard.