Nqueen problem using recursion

when we have 2 x 2 chessboard so what will be the position of queen and i didn’t get how to compute the indices of diagonals to check if the queen pos is safe or not

@Vikaspal for a 2x2 chessboard queens can be places like
q .
. q

@Ishitagambhir but here the diagonal elements cut each other the pos of all should be safe ?

@Vikaspal sorry my bad, no solution exists for n = 2. It must be given in the question what to print if a solution does not exist :slight_smile:
Do you have any other query?

yes I didn’t understand how the all the configuration is achieved ?. If one approach is that we can fill the queen rowbyrow and colbycol right , so two possible ways?

@Vikaspal https://codingblocks.com/resources/n-queen-using-backtracking/ you can refer to this :slight_smile:

one question that when we have to for loop and inside that we have if condition which return true if condition met then so the code after the if condition is not going to execute ?

@Vikaspal if you use “continue” in that if condition then it will not, otherwise it will

@Ishitagambhir thanks so if I use continue keyword after the return statement then the loop will be continue.

1 Like

@Vikaspal yes it will jump over to the next iteration.

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.