2-SUM algorithm