Given an array S of n integers, are there elements x, y, z in S such that x + y + z = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
- Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
- The solution set must not contain duplicate triplets.
一个重要的优化就是如果上个数已经求过集合了 例如[-1 -1 0 2 2]已经包含了[-1 0 2 2] 当然也包含了 [-1 0 2]集合的。