Pregunta de entrevista de One Acre Fund

How would you optimize this code?