@@ -0,0 +1,1269 @@
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0A// 311/48ms/11.70%25%0Aclass ThreeSum %7B%0A  public List%3CList%3CInteger%3E%3E threeSum(int%5B%5D nums) %7B%0A    Arrays.sort(nums);%0A    List%3CList%3CInteger%3E%3E list = new ArrayList%3C%3E();%0A    Set%3CInteger%3E targets = new HashSet%3C%3E();%0A%0A    for (int target = 0; target %3C nums.length; target++) %7B%0A      if (!targets.contains(nums%5Btarget%5D)) %7B%0A        Set%3CInteger%3E set = new HashSet%3C%3E();%0A        List%3CInteger%3E previousList = new ArrayList%3C%3E();%0A%0A        for (int i = target + 1; i %3C nums.length; i++) %7B%0A          if (set.contains(-nums%5Btarget%5D - nums%5Bi%5D)) %7B%0A            List%3CInteger%3E innerList = new ArrayList%3C%3E();%0A            innerList.add(nums%5Btarget%5D);%0A            innerList.add(-nums%5Btarget%5D - nums%5Bi%5D);%0A            innerList.add(nums%5Bi%5D);%0A%0A            if (!innerList.equals(previousList)) %7B%0A              list.add(innerList);%0A              previousList = innerList;%0A            %7D%0A          %7D else %7B%0A            set.add(nums%5Bi%5D);%0A          %7D%0A        %7D%0A        targets.add(nums%5Btarget%5D);%0A      %7D%0A    %7D%0A    return list;%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    System.out.println(new ThreeSum().threeSum(new int%5B%5D %7B4, 0, -1, -1, -1, 2, 2, 2, 2, 0, 0, 0, -4%7D));%0A  %7D%0A%7D

Add solution 15 Java