
15.3Sum
Description:
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note: The solution set must not contain duplicate triplets.
题目理解:输入一个数组和一个目标值,求3个数之和等于目标值。返回所有这些3个数的组合,但是不能有重复的组合。
|
|
首先将数组进行排序,外层循环从左向右,内部就是一个Two_Sum,这里注意要跳过重复的值。
复杂度n^2,运行时间69ms。





近期评论