InterviewBit Academy is now Scaler!
Learn Tech Skills from Scratch @ Scaler EDGE

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.
Return the sum of the three integers.

Assume that there will only be one solution

given array S = {-1 2 1 -4},
and target = 1.

The sum that is closest to the target is 2. (-1 + 2 + 1 = 2)

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving 3 Sum on Interview Code Editor
Sign Up
to access hints and editorial solutions for 3 Sum


Click here to start solving coding interview questions