Google interview question

Time and space complexity of implementation