leetCode 51 N-Queens (Backtracking) | JSer - algorithm and JavaScript

preview_player
Показать описание
leetCode 51 N-Queens (Backtracking)
A typical backtracking problem similar to the Sudoku problem we've tackled.
The result is complex 2D array, so we use a global array to generate the result. When certain condition is met, we collect the real results. The idea to use extra flag array is the same as Sudoku problem.

Hi I'm a JavaScript engineer who is not good at algorithms,
and currently practicing leetCode online. If you are interested, maybe we can learn together.
Рекомендации по теме
Комментарии
Автор

Thank you for this man, what are the colUsed and diagolUserds I mean I know what they represents but I don't understand what they are in the code you declare them without initial value then you check id they in a given index j are are ture or not and in another line you assign them a true or false value ... are they boolean arrays ?

armandopenaleonett
Автор

Hi, I have a doubt when n is 4 its 4x4 matrix right then why diago135Used & diago45Used arrays length is 7.

suriyasuriyan
Автор

I appreciate the effort, but this is not good. You are very smart though! Much smarter than me.

seymour_videos