Google interview question

time complexity and space complexity