public List<List<Integer>> threeSum(int[] nums) { Set<List<Integer>> res = new HashSet<>(); int n = nums.length;
if(n < 3){ returnnew ArrayList<>(res); }
Arrays.sort(nums); for (int i = 0; i < n - 2; i++) { int j = i + 1; int k = n - 1; while (j < k){ if (nums[i] + nums[j] + nums[k] > 0){ k--; }elseif (nums[i] + nums[j] + nums[k] < 0){ j++; }else { List<Integer> list = new ArrayList<>(); list.add(nums[i]); list.add(nums[j]); list.add(nums[k]); res.add(list);