DHEERAJHARODE / Hacktoberfest2024-Open-source-

Send your valuable codes here
MIT License
396 stars 3.13k forks source link

Create N queen Problem #2533

Open PRASANNAPATIL12 opened 11 months ago

PRASANNAPATIL12 commented 11 months ago

solveNQueens is the main entry point that initializes an array to represent the board and starts the recursive placeQueens function.

placeQueens is a recursive function that attempts to place queens on the board row by row. If it successfully places all queens, it prints the board.

isSafe checks if it's safe to place a queen at a specific row and column without conflicting with the existing queens.

printQueens prints the chessboard with queens placed.

In the main method, you can change the value of n to the desired board size and call solveNQueens to find and print the solutions.