On recursive call the number of values in set remain same, instead of getting updated to previous values
for certain 5 recursions, while in upstream the values get updated in attackSet2 as 1, 2,3,4,5 So while in downstream recursive calls the values should become 4, 3, 2, 1 But instead of that it remains 5.
private int placeQueen(int x, int y, int count, int t, int n, HashMap<String, Pair> mainSet, Set<Pair> attackSet, Set<Pair> attackSet2) {
attackSet.addAll(attackzone(x,y,n,mainSet));
attackSet2.add(new Pair(x, y));
n--;
if (n<=0) {
count2++;
return 1;
}
for (int i=0; i<t; i++) {
for (int j=0; j<t; j++) {
if (!attackSet.contains(mainSet.get(i+","+j))) {
count = count + placeQueen(i, j, count, t, n, mainSet, attackSet, attackSet2);
// return placeQueen(i, j, count, t, n, mainSet, attackSet);
}
}
}
return count;
}