Meta interview question

Basic algorithmic question. Improve time and space complexity.