Interactive Brokers interview question

Just started with average array questions and then asked for their optimization.