One Acre Fund Interview Question

How would you optimize this code?