What's wrong with my code?Title of your comment


#1

void dfs(int i,int j,int dx[],int dy[],vectorA,vector<vector>vis,int n,int m){
vis[i][j]=1;
for(int k=0;k<4;k++){
int newx=i+dx[k];
int newy=j+dy[k];
if(newx<0 || newx>n || newy<0 || newy>m){
continue;
}
else if(A[newx][newy]==‘X’ && !vis[newx][newy]){
dfs(newx,newy,dx,dy,A,vis,n,m);
}
}
}
int Solution::black(vector &A) {
int n=A.size();
int m=A[0].size();
vector<vector>vis(n,vector(m,false));
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
int c=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(A[i][j]==‘X’ && !vis[i][j]){
dfs(i,j,dx,dy,A,vis,n,m);
c++;
}
}
}
return c;
}


#2

Use & in decleration of dx,dy,A,vis in dfs