# I got different result comparing with my local machine

• This is my code. It is quite straight forward.

``````class Solution {
public:
void solve(vector<vector<char> > &board) {
if(board.size()<3||board[0].size()<3)
return;
vector<vector<char> > cpboard(board.size(),vector<char>(board[0].size(),'X'));

int row=board.size()-1;
int col=board[0].size()-1;
for(int i=0;i<board[0].size();i++){
if(board[0][i]=='O'){
val(0,i,board,cpboard);
}
if(board[row][i]=='O'){
val(row,i,board,cpboard);
}
}
for(int i=1;i<row;i++){
if(board[i][0]=='O')
val(i,0,board,cpboard);
if(board[i][col]=='O')
val(i,col,board,cpboard);
}
board.clear();
board=cpboard;

return;
}

void val(const int& row, const int& col, vector<vector<char> > &board, vector<vector<char> > &cpboard){
static int rowmax=board.size()-1;
static int colmax=board[0].size()-1;
int index=row*board[0].size();

cpboard[row][col]='O';

if(row>0){
if(board[row-1][col]=='O')
if(cpboard[row-1][col]=='X'){
val(row-1,col,board,cpboard);
}
}
if(row<rowmax){
if(board[row+1][col]=='O')
if(cpboard[row+1][col]=='X'){
val(row+1,col,board,cpboard);
}
}
if(col>0){
if(board[row][col-1]=='O')
if(cpboard[row][col-1]=='X'){
val(row,col-1,board,cpboard);
}
}
if(col<colmax){
if(board[row][col+1]=='O')
if(cpboard[row][col+1]=='X'){
val(row,col+1,board,cpboard);
}
}
}
};
``````

• `static` might be the problem.

• Yes, you are right! that is the problem! Thank you so much!

• Yes, you are right! that is the problem! Thank you so much! And would you be so kind to tell me why the keyword "static" could results in such problems?

• Because OJ run your code once to test all testcase. It would be better to post code with some detail explanation for asking question in LeetCode Discuss. That is why your post is closed.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.