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)
3 sum 的变形题
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)
本文标题:3 sum closest
本文链接:https://www.haomeiwen.com/subject/rxkaeftx.html
网友评论