Question
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.
1 |
|
Analysis
这道题的思路还算是比较清晰的,排序,然后两个指针一前一后搜索合适的解就可以了。主要是题目要求unique triplets,就需要合理的排除掉重复的解。
Solution
1 |
|
1 |
|
1 |
|