deftwoSum(nums, start, target): low, high = start, len(nums)-1 res = [] while low<high: sumLR = nums[low]+nums[high] left, right = nums[low], nums[high] if sumLR<target: while low<high and nums[low]==left: low+=1 elif sumLR>target: while low<high and nums[high]==right: high-=1 else: res.append([left, right]) while low<high and nums[low]==left: low+=1 while low<high and nums[high]==right: high-=1 return res
i=0 while i< length: subRes = twoSum(nums, i+1, 0-nums[i]) for sub in subRes: sub.append(nums[i]) res.append(sub) while i<length-1and nums[i]==nums[i+1]: i+=1 i+=1 return res # @lc code=end