GlobalLogic interview question

Algorithms and questions regarding time and space complexity