16. 3Sum Closest
Difficulty: Medium
在数组中找出和target最接近的三个数的和
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. You may assume that each input would have exactly one solution.
1 | For example, given array S = {-1 2 1 -4}, and target = 1. |
My Solution O(n^2)
1 | class Solution { |