ServiceNow interview question

To write code in O(n) complexity.