SubSet of array in java / subsequence of array in java
static Boolean isSubsetSum(int N, int arr[], int target){
// code here
ArrayList<ArrayList<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
for(int i=0;i<N;i++){
int n=list.size();
for(int j=0;j<n;j++){
ArrayList<Integer> temp = new ArrayList<>(list.get(j));
temp.add(arr[i]);
list.add(temp);
}
}
}
return false;
}
Comments
Post a Comment