Pergunta de entrevista da empresa ChannelNet

How would you optimize this algorithm?