Pregunta de entrevista de ServiceNow

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