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]集合的。