leetCode 50 (N-Queens):
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
solution: each potentional position for a queen should satisfy no attach, then traverse the 2D grids to find out all good positions; it requires to find all possible combinations, so recursive call will be used also.
|
|
I did actually new memory in C++ as following:
|
|
which failed, then realized only malloc works in this way.