3 sum closest

2018-06-19  本文已影响11人  世界你好

3 sum 的变形题

Solution1:

sort first, then iterate the array, fix one element,  using two pointer to calculate the sum for 3 elements, using absolute value to determine which is the closest result.

time: O(n^2), space: O(1)

上一篇 下一篇

猜你喜欢

热点阅读