Pergunta de entrevista da empresa J.P. Morgan

How could you improve your code and go through the thought process