N queen coding sol

I got the concept of N queen problem… but i am not able to write the code
how should i approach… how should i think?

@chaman9 hey use this algo to write your code:

  1. Start in the leftmost column
  2. If all queens are placed
    return true
  3. Try all rows in the current column.
    Do following for every tried row.
    a) If the queen can be placed safely in this row
    then mark this [row, column] as part of the
    solution and recursively check if placing
    queen here leads to a solution.
    b) If placing the queen in [row, column] leads to
    a solution then return true.
    c) If placing queen doesn’t lead to a solution then
    unmark this [row, column] (Backtrack) and go to
    step (a) to try other rows.
  4. If all rows have been tried and nothing worked,
    return false to trigger backtracking.

okay thanks… i will try out

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.