Domanda di colloquio di Wrike

Write a function to solve a basic problem keeping o(n) in mind.