Question d’entretien chez Amazon

it was a leetcode hard question