Amazon Interview Question

worst case Time complexity of the solution that I gave