MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / isSafe

Method isSafe

Backtracking/Code/nQueens.cpp:14–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 vector<vector<int>> ans;
13
14 bool isSafe(vector<vector<int>>& board, int r, int c, int n){
15 for(int i=0;i<r;i++){
16 if(board[i][c]==1){
17 return false;
18 }
19 }
20
21 for(int i=r-1,j=c-1;i>=0 && j>=0; i--,j--){
22 if(board[i][j]==1){
23 return false;
24 }
25 }
26
27 for(int i=r-1,j=c+1;i>=0 && j<n; i--, j++){
28 if(board[i][j]==1){
29 return false;
30 }
31 }
32
33 return true;
34 }
35
36 void helper(vector<vector<int>>& board, int n,int r){
37 if (r==n){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected