Keeping track of index is the key thing to avoid duplicates.

```
public class Solution {
public List<List<Integer>> combinationSum(int[] candidates, int target) {
Arrays.sort(candidates);
List<List<Integer>> results = new ArrayList<>();
List<Integer> combi = new ArrayList<>();
combinationSum(candidates,target,results,combi,0);
return results;
}
public void combinationSum(int[] candidates, int target,List<List<Integer>> results,List<Integer> combi, int index) {
for(int i=index;i<candidates.length;i++){
int remaining = target - candidates[i];
if (remaining == 0){
combi.add(candidates[i]);
results.add(new ArrayList<Integer>(combi));
combi.remove(combi.size()-1);
return;
} else if (remaining > 0) {
combi.add(candidates[i]);
combinationSum(candidates,remaining,results,combi,i);
combi.remove(combi.size()-1);
}
}
}
}
```