3Sum Closest Problem

3Sum Closest Problem — ExecCode Medium DSA Practice

Solve the 3Sum Closest problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

3Sum Closest. Sort + two pointers track best. For 3Sum Closest, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.

Examples

Input {"nums": [-1, 2, 1, -4], "target": 1}; Output 2

Constraints

1 ≤ n ≤ 10^5

Practice 3Sum Closest free on ExecCode. Browse DSA problems, topic map, and placement guides.