ServiceNow Interview Question

Coding question: TwoSum - Brute force and then how would I improve it without using hash.