Edit distance : failing test cases

#include
#include<string.h>
using namespace std;
int editDist(string str1,string str2){
int dp[2001][2001];
int l1=str1.length();
int l2=str2.length();
dp[0][0]=0;
for(int i=1;i<=l1;i++){
dp[i][0]=dp[i-1][0]+1;
}
for(int i=1;i<=l2;i++){
dp[0][i]=dp[0][i-1]+1;
}

for(int i=1;i<=l1;i++){
    for(int j=1;j<=l2;j++){
    
        dp[i][j]=min( dp[i-1][j], min( dp[i][j-1],dp[i-1][j-1] ) ) + (str1[i-1]!=str2[j-1]);
        
    }
}
return dp[l1][l2];

}

int main() {
char str1[2000],str2[2000];
cin.getline(str1,2000);
cin.getline(str2,2000);
cout<<editDist(str1,str2);
return 0;
}

hi isha
there were small errors in your code
i have added comments. see through it. if you still have any doubts you can ask further

It has been failing the same test cases even now.

hi isha
actually the getline statements was creating problem
simple input is required and it is assumed that the string will not contain spaces it is single word only

Yes,got it.Thanks a lot !

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.