So I was trying to solve N-Queen's problem using java and tried to use
for (int r = row, c = col; r >= 0 && c < board.length; r--, c++) {
// Loop body
}
which according to me should check the upper right diagonal, but for some reason my solution was producing weird output and I checked some solutions where they have used
for (int r = row, c = col; r >= 0 && c < board.length; c++, r--) {
// Loop body
}
So that got me to wonder does this order of c++, r-- in the for loop matters? If yes, how exactly?