N Queen count problem

i cant find the count for n queen i tried it with global variable but i also had tried with the return approach both didnt work . Please help.

Hello @hrithik-1 there are lot of mistakes in your code i recommend you to watch the video again and then again try to implement your code:
Here for your reference i am attaaching the correct code:


if you have any doubt you can ask here:
Happy Learning!!

Can you teel me is the isSafe() function is wrong or not

Hello @hrithik-1 yes there are errors in it as well.
basically we have to check the diagomals only in it.
like for the left diagonal we will start from the current location and we will decrement it till both these variables are greater then zero.
and for the right diagional we haver to check in the way like from the current location we will start decrememting the row and start incrementing the column till the rows reaches to the first row and the columns reaches to the end column.
and other than this we have to check if it has any queen in that particular column as well.
if you will find any queen in any row or column then we will return false and try for any other position.
if you have any other doubt you can ask here:
Happy Learning!!

thanks it worked …

@hrithik-1 if you feel that your doubt is cleared you can mark this as resolved.
Happy Learning!!

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.