Accepted leetcode sol for the same


#1

class Solution {
List<List> resultList = new ArrayList<List>();
public List<List> combinationSum(int[] candidates, int target) {

   Stack<Integer> stackObj = new Stack<Integer>();
getList(0, candidates.length-1, candidates,  target, stackObj);
return resultList;
    
}

private void getList(int low , int high, int[] candidates, int target, Stack<Integer> stackObj){
if(low > high)
  return;

if(target == 0){
  resultList.add(new ArrayList<Integer>(stackObj));
  return;
}

if(candidates[low] > target){
  getList(low+1, high, candidates, target, stackObj);
  return;
}

stackObj.push(candidates[low]);
getList(low, high, candidates, target-candidates[low], stackObj);

stackObj.pop();
getList(low+1, high, candidates, target, stackObj);

}

}