DFS question

Posted by callampaman@reddit | learnprogramming | View on Reddit | 0 comments

Recently I had to code an algorithm to solve the N queens problem and I used DFS. If you don't know what this problem is, it's very simple. It's about checking if you can put n queens on a n x n board without any of them being in their eating pattern. Basically I made a matrix (double vector) as the board, where the parts you can place a new queen are 0, and if you place a queen, the box number will be changed to 1 and its eating pattern too. My teacher said it was "not in the DFS logic" but I've seen other solutions in GeekForGeeks that use a similar logic and it is recursive and the ones erase once it backtracks. Is my teacher wrong? I'd appreciate your help.