Salesforce Interview Question

Algorithm question: pretty similar to two sum.