Back tracking 1D Queen Permutation

in for loop or i=0 i understood,but for the next iterations i could not understand

Hi @maminibeerappa.
We are using backtracking to remove the queen from a box (the undo step) and putting it in another box.

After that we put first check for boxes[i] is false or not. This means that if there is a queen already present in boxes[i], we will not put another queen there.

For example if q0 is present in box[0] we cannot put q1 in box[0], hence we first check and then when the recursive call is complete we, we undo our step, that is remove the queen from the box.

And if queens placed so far is equal to target queens we will print our result and return. So this will be our base case.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.