Pregunta de entrevista de Microsoft

Optimization Question: optimize code I wrote in interview