Domanda di colloquio di Amazon

Problem similar to something in cracking the coding interview