15. 3Sum
Given an array nums
of n integers, are there elements a, b, c in nums
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.
Example:
解题要点:
先从头开始遍历,然后同时用双指针处理找后面是否有符合条件的数字,加入到最终返回值里。(剪枝:重复的不作处理,直接跳过)
Last updated
Was this helpful?