20-line, elegant accepted JAVA solution using Backtracking.
The key idea is using backtracking. But before each step, I checked the eligibility of i-th element in the array before adding it to the subset list. Basically 
The key idea is using backtracking. But before each step, I checked the eligibility of i-th element in the array before adding it to the subset list. Basically a lower and an upper boundaries were added to each backtracking step.\n```\n    public List<List<Integer>> fourSum(int[] nums, int target) {\n        List<List<Integer>> ans = new ArrayList<List<Integer>>();\n        if(nums == null || nums.length == 0) return ans;\n        List<Integer> list = new ArrayList<>();\n        Arrays.sort(nums);\n        getSum(nums, 0, target, ans, list, 0);\n        return ans;\n    }\n    private void getSum(int[] nums, int sum, int target, List<List<Integer>> ans, List<Integer> list, int pos){\n        if(list.size() == 4 && sum == target && !ans.contains(list)){\n            ans.add(new ArrayList<>(list)); return;\n        }else if(list.size() == 4) return;\n        for(int i = pos; i < nums.length; i++){\n            if(nums[i] +  nums[nums.length - 1] * (3 - list.size()) + sum < target) continue;\n            if(nums[i] * (4 - list.size()) + sum > target) return;\n            list.add(nums[i]);\n            getSum(nums, sum + nums[i], target, ans, list, i + 1);\n            list.remove(list.size() - 1);\n        }\n    }\n```
[]