Given an array of n integers and an integer “key”, find three integers in the array such that the sum is closest to key.

Input: [-1, 2, 1, -4] Key = 1 Output: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2) This problem is also known as three sum closest  The solution to this problem is similar to “two sums”. Hence I would recommend you to please check out the … Continue reading Given an array of n integers and an integer “key”, find three integers in the array such that the sum is closest to key.