Two sum closest to target
Your task
Given an integer array a (possibly with negatives, length >= 2) and an integer target, pick two distinct elements whose sum is closest to target. Return that sum (the value of the closest sum, not the indices). If two sums are equally close, return either.
Examples
closest_pair_sum(a: list[int], target: int) -> intExample 1
Input
closest_pair_sum([1, 2, 3, 4, 5], 8)Output
8