ServiceNow Interview Question

To write code in O(n) complexity.