@@ -0,0 +1,1475 @@
+/**%0A * Problem Link: https://leetcode.com/problems/3sum/%0A * %0A * Use ith number as the first number a,%0A * then, using two pointers to find the other two numbers.%0A */%0Apublic class Solution %7B%0A    public List%3CList%3CInteger%3E%3E threeSum(int%5B%5D nums) %7B%0A        List%3CList%3CInteger%3E%3E list = new ArrayList%3CList%3CInteger%3E%3E();%0A        int n = nums.length;%0A        if(n %3C 3) return list;%0A        %0A        Arrays.sort(nums);%0A        %0A        for(int i=0; i%3Cn-2; i++) %7B%0A            // Remove the duplicate numbers.%0A            if(i==0 %7C%7C nums%5Bi%5D != nums%5Bi-1%5D) %7B%0A                int target = -nums%5Bi%5D;%0A                int p1 = i + 1;%0A                int p2 = n - 1;%0A                while(p1 %3C p2) %7B%0A                    if(nums%5Bp1%5D + nums%5Bp2%5D == target) %7B%0A                        List%3CInteger%3E ret = new ArrayList%3CInteger%3E();%0A                        ret.add(nums%5Bi%5D);%0A                        ret.add(nums%5Bp1%5D);%0A                        ret.add(nums%5Bp2%5D);%0A                        list.add(ret);%0A                        p1++;%0A                        p2--;%0A                        // Remove the duplicate numbers.%0A                        while(p1 %3C p2 && nums%5Bp1%5D == nums%5Bp1-1%5D) p1++;%0A                        while(p1 %3C p2 && nums%5Bp2%5D == nums%5Bp2+1%5D) p2--;%0A                    %7D else if (nums%5Bp1%5D + nums%5Bp2%5D %3E target) %7B%0A                        p2--;%0A                    %7D else %7B%0A                        p1++;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return list;%0A    %7D%0A%7D%0A

Create 3Sum.java