One Acre Fund interview question

How would you optimize this code?