Garmin Interview Question

They gave me a code and asked me how I could optimize it.