Netvirta interview question

Evaluate the complexity of the algorithm