Pregunta de entrevista de ClearMotion

How would you optimize the time complexity of your algorithm?