Indeed interview question

About the complexity(time and space) and optimization.