Question d’entretien chez Arm

What was your thought process when solving this coding problem? What would you improve?