O(n^3) solution is trivial is there any O(n^2logn) algorithm
Any Better algorithm than O(n^3) time complexity.\n\n    public class Solution {\n            public List> fourSum(int[] num, int target) {\n                Lis
Any Better algorithm than O(n^3) time complexity.\n\n    public class Solution {\n            public List<List<Integer>> fourSum(int[] num, int target) {\n                List<List<Integer>> results = new LinkedList<List<Integer>>();\n                if (num == null || num.length < 4)\n                    return results;\n                Arrays.sort(num);\n        \n                for (int s = 0; s < num.length - 3; s++) {\n                    if (s > 0 && num[s] == num[s - 1])  continue;\n        \n        \n                    for (int e = num.length - 1; e >= s + 3; e--) {\n                        if (e < num.length - 1 && num[e] == num[e + 1]) continue;\n        \n                        int local = target - num[s] - num[e];\n                        int j = s + 1;\n                        int k = e - 1;\n                        while (j < k) {\n        \n                            if (j > s + 1 && num[j] == num[j - 1]) {\n                                j++;\n                                continue;\n                            }\n                            if (k < e - 1 && num[k] == num[k + 1]) {\n                                k--;\n                                continue;\n                            }\n        \n                            if ((num[j] + num[k]) > local)\n                                k--;\n                            else if ((num[j] + num[k]) < local)\n                                j++;\n                            else\n                                results.add(new ArrayList<Integer>(Arrays.asList(\n                                        num[s], num[j++], num[k--], num[e])));\n                        }\n                    }\n                }\n                return results;\n            }\n        }
[]