Skip to content

Instantly share code, notes, and snippets.

@prajwal27
Created October 29, 2018 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prajwal27/c725dcd2b648a53d7e948fe48c15cd5c to your computer and use it in GitHub Desktop.
Save prajwal27/c725dcd2b648a53d7e948fe48c15cd5c to your computer and use it in GitHub Desktop.
void c(vector<string> &A,int i,int j)
{
if(i<0 || j<0 || j>=A[0].size() || i >=A.size())
return;
if(A[i][j]=='O')
return;
A[i][j]='O';
c(A,i+1,j);
c(A,i-1,j);
c(A,i,j-1);
c(A,i,j+1);
}
int Solution::black(vector<string> &A) {
int count = 0;
int i,j;
for(i=0;i<A.size();i++)
{
for(j=0;j<A[0].size();j++)
{
if(A[i][j]=='X')
{
c(A,i,j);
count++;
}
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment