Google interview question

Algorithm, time complexity of code