Question d’entretien chez Google

Technical coding question with decent difficulty