TwoSum algorithm