# The online judge has err

• if I am wrong please correct me, my code which do not consider the dup answers, can still pass the oj.

out put is :[[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]

``````    public static ArrayList<ArrayList<Integer>> combinationSum(int[] candidates, int target) {
ArrayList<ArrayList<Integer>> r = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> path = new ArrayList<Integer>();
Arrays.sort(candidates);
if(candidates.length==0)
return r;
help(candidates,target,r,path,0);
return r;
}

public static void help(int[] c, int sum,ArrayList<ArrayList<Integer>> r,ArrayList<Integer> path,int index){
if(sum==0){
return ;
}
for(int i=index;i<c.length;i++){
if(sum-c[i]<0)
return;
help(c,sum-c[i],r,path,i);
path.remove(path.size()-1);
}
}

public static void main(String[] args){
int[] a = {1,1,1,1,1,1,1};
System.out.print(combinationSum(a,2));
}``````

• Your test case seems not satisfied the condiftion of a SET of candidate numbers, set means no duplicated numbers.

You should try the the problem 'Combination Sum II', I believe that is what you mentioned.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.