Cant find runtime error someone please help


  • 0
    A
    public:
    bool wor(vector<vector<char>>& board,string word,int i,int j,int  x)
    {
       
    
           if(board[i][j]!=word[x] || i<0 || j<0 || i>=board.size() || j>=board[0].size() || board[i][j]=='*')
             return false;
        
       if(x==word.length())
        return true;
        cout<<x<<endl;
        cout<<word.length();
        cout<<word[x]<<endl;
       
                cout<<"hi";
                char ch=board[i][j];
               board[i][j]='*';
                    if(wor(board,word,i-1,j,x+1) || wor(board,word,i+1,j,x+1) || wor(board,word,i,j-1,x+1) || wor(board,word,i,j+1,x+1))
                    return true;
                 cout<<"i";
                board[i][j]=ch;
        return false;
        
        
    }
    
    
    
        bool exist(vector<vector<char>>& board, string word) {
            
            int i,j;
            for(i=0;i<board.size();i++)
            {
                for(j=0;j<board[i].size();j++)
                {
                    
                    
                   
       
               
                    if(wor(board,word,i,j,0))
                    return true;
                    
                }
            }
            return false;
            
            
        }
    };

Log in to reply
 

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