Domanda di colloquio di Microsoft

How would you solve this python problem.