```
class Solution {
public:
int m, n ;
void flood(vector<vector<char> >& a, int x, int y, char old , char neW){
if(x < 0|| x >= m || y < 0 || y >= n)
return ;
if(a[x][y] != old)
return ;
a[x][y] = neW;
flood(a,x+1,y,old,neW);
flood(a,x-1,y,old,neW);
flood(a,x,y+1,old,neW);
flood(a,x,y-1,old,neW);
}
void solve(vector<vector<char>>& a) {
if(a.empty()) return ;
m = a.size();
n = a[0].size();
for(int i = 0 ; i < m; i++){
for(int j = 0; j < n ; j++){
if(a[i][j] == 'O'){
a[i][j] = '-';
}
}
}
for(int i = 0; i < m; i++){
if(a[i][0] == '-'){
flood(a,i,0,'-','O');
}
}
for(int i = 0; i < m; i++){
if(a[i][n-1] == '-'){
flood(a,i,n-1,'-','O');
}
}
for(int i = 0; i < n; i++){
if(a[0][i] == '-'){
flood(a,0,i,'-','O');
}
}
for(int i = 0; i < n; i++){
if(a[m-1][i] == '-'){
flood(a,m-1,i,'-','O');
}
}
for(int i = 0; i < m ; i++){
for(int j = 0; j < n ;j++){
if(a[i][j] == '-')
a[i][j] = 'X';
}
}
}
```

};