Amazon Interview Question

Make true that ur algorithm is not just correct, but also be efficient in time complexity and space complexity.