Domanda di colloquio di Udemy

How would you solve the following coding challenge?