HubSpot Interview Question

How would you reduce the O(n) complexity?