Pergunta de entrevista da empresa Susquehanna International Group

How would you optimize the alogirthm into something better