Find the largest pair sum that's still strictly less than k. Sort first,
then converge: a sum under k is a candidate answer — record it and try to do
better by moving left up; a sum at or over k is too big, so pull right down.
Execution
idle
Press Run to begin.
0 / 0
Speed
Java · running line
leftrightcurrent best pair
O(n log n) time (dominated by the sort) · O(1) extra space · unlike Two Sum, there's no early exit — every sum under k is only a candidate, not necessarily the best one.