Question d’entretien chez Amazon

Problem similar to something in cracking the coding interview