Pergunta de entrevista da empresa Amazon

worst case Time complexity of the solution that I gave