Pergunta de entrevista da empresa Bloomberg

(after solving the problem) What is the computational complexity in big-O notation?