Compilation Error


  • 0
    P

    What is the syntax error in this code? I couldn't figure out any.
    On compilation it prompts "required from here".
    I am not able to figure out what this means.

    class Solution {
    public:
    int minDistance(string word1, string word2) {

        int m=word1.size(),n=word2.size();
        int dp[m+1][n+1];
        for(int i=0;i<=m;i++)
        {
            for(int j=0;j<=n;j++)
            {
                if(i==0)
                dp[i][j]=j;
                else if(j==0)
                dp[i][j]=i;
                else if(word1[i-1]==word2[j-1])
                dp[i][j]=dp[i-1][j-1];
                else
                dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+1);
            }
        }
        return dp[m][n];
        
    }
    

    };


Log in to reply
 

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