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

Method helper

Backtracking/Homework/nQueens.cpp:36–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 }
35
36 void helper(vector<vector<int>>& board, int n,int r){
37 if (r==n){
38 vector<int> temp;
39 for(int i=0;i<n;i++){
40 for(int j=0;j<n;j++){
41 if(board[i][j]==1){
42 temp.push_back(j+1);
43 }
44 }
45 }
46 ans.push_back(temp);
47 return;
48 }
49
50 for(int i=0;i<n;i++){
51 if(isSafe(board,r,i,n)){
52 board[r][i]=1;
53 helper(board,n,r+1);
54 board[r][i]=0;
55 }
56 }
57 }
58 vector<vector<int>> nQueen(int n) {
59 // code here
60 vector<vector<int>> board(n,vector<int>(n,0));

Callers

nothing calls this directly

Calls 2

isSafeFunction · 0.70
helperFunction · 0.70

Tested by

no test coverage detected