Pergunta de entrevista da empresa Agnity

Write a program for reducing space and time complexity.