C++ O(m*n) easy


#1
int Solution::isInterleave(string A, string B, string C)
{
    int r=A.size(),c=B.size();
    vector<vector<bool>>V(r+1,vector<bool>(c+1,0));
    for(int i=0;i<=r;i++)
    {
        for(int j=0;j<=c;j++)
        {
            if(i==0&&j==0)
            V[i][j]=1;
            else if(i==0)
            V[i][j]=C[i+j-1]==B[j-1]&&V[i][j-1];
            else if(j==0)
            V[i][j]=C[i+j-1]==A[i-1]&&V[i-1][j];
            else
                V[i][j]=((C[i+j-1]==A[i-1]&&V[i-1][j])||(C[i+j-1]==B[j-1]&&V[i][j-1]));
        }
    }
    return V[r][c];
}