Pergunta de entrevista da empresa Pigment

As always, time complexity for the algorithm exercise