Question d’entretien chez Amazon

Explain your code from the online assessment (for both problems).