Wrike interview question

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