Question d’entretien chez Udemy

How would you solve the following coding challenge?