ServiceNow interview question

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