Did not understand that diagonal concept!!
can you explain me how the code is working for diagonal??
N queen using backtracking
so basically what is happening here is that if suppose u are at
3,2 ( 0 index based) & checking for left diagonal
then u will be going leftwards
and the boundary condition for that will be
i >=0 and j >=0 and since we are moving left diagonal so both x-- ,y-- happens
in the case of right diagonal
the boundary condition to the right upper boundary is
x< n and y >=0
and since y cordinate is increasing so y++ and x-- ( moving upwards)
yeah I understood this but before giving X-- and Y-- why we are printing return false??
if u find that u have already a queen placed in that position that means that queen can kill the present queen since queen can make diagonal move hence
we return false
to show that the queen cannot be placed
and please do elaborate the next time which part u have understood and what uhave not it is a lot of effort a to draw it .
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.