Pergunta de entrevista da empresa EPAM Systems

Why is that solution best solution? Time complexity and space complexity