Amazon interview question

Complexity of the code written.