GitLab interview question

What are the optimization that can be done with this code?