Closest Pair Sum
Medium ยท Time limit 1s
Given an array of integers and a target value, find the pair whose sum is closest to the target. Return the closest sum value.
Input Format
- First line:
n target - Second line:
nintegers
Output Format
- A single line with the closest sum value
Example
Input
4 10
1 2 7 8
Output
9
Constraints
2 \leq n \leq 10^5-10^4 \leq \text{value} \leq 10^4-10^6 \leq \text{target} \leq 10^6
Loading...
Test Results
Run tests to see results.