Amazon Interview Question

Complexity of the code written.