Created
October 29, 2018 02:59
-
-
Save prajwal27/c725dcd2b648a53d7e948fe48c15cd5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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