← Goldman Sachs questions

2-sum pair sum closest to target using binary search

Filed under Goldman Sachs

Given a sorted array of integers and a target value, find a pair of elements whose sum is closest to the target. Additionally, consider finding a pair whose difference is closest to the target.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Goldman Sachs questions

Collected from public candidate posts and coding forums. Updated Nov 2026.