Goldman Sachs Interview Question

Write a program in o(n) complexity