Agnity interview question

Write a program for reducing space and time complexity.