Different results in OJ and offline IDE


  • 0
    S

    Here is my code.

    public class Solution {
        public void solve(char[][] board) {
            if(board==null || board.length<3 || board[0].length<3){
                return;
            }
            
            int height = board.length;
            int width = board[0].length;
            for(int i=1;i<height-1;i++){
                for(int j=1;j<width-1;j++){
                    if(board[i][j]=='o'){
                        if( (board[i-1][j]=='x' || board[i-1][j]=='y') && (board[i][j-1]=='x' || board[i][j-1]=='y') ){
                            board[i][j] = 'y';
                        }
                    }
                }
            }
            
            for(int i=height-2;i>0;i--){
                for(int j=width-2;j>0;j--){
                    if(board[i][j]=='y'){
                        if( board[i+1][j]=='x'  && board[i][j+1]=='x' ){
                            board[i][j] = 'x';
                        }else{
                            board[i][j] = 'o';
                        }
                    }
                }
            }
        }
    }
    

    The OJ returned such an error:

    Input:	["XXX","XOX","XXX"]
    Output:	["XXX","XOX","XXX"]
    Expected:	["XXX","XXX","XXX"]
    

    However, the code can result the expected answer in Netbeans when runned offline. What is the problem? THX.


  • 0
    X

    you are using small x and o, you should use big X and O


  • 0
    Q

    I have exactly the same problem with you! wired.


Log in to reply
 

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