Intuit Interview Question

1. How to optimize the code