My code gives output 5

#include
#include
#include
using namespace std;

int editDist(char inp[100],char out[100])
{
int dp[101][101]={0};
int m=strlen(inp);
int n=strlen(out);
dp[0][0]=0;
for(int r=1;r<=m;r++)
dp[r][0]=dp[r-1][0]+1;
for(int c=1;c<=n;c++)
dp[0][c]=dp[0][c-1]+1;
for(int i=1;i<=m;++i)
{
for(int j=1;j<=n;++j)
{
int q1=dp[i][j-1]; //insertion
int q2=dp[i-1][j-1]; //replacement
int q3=dp[i-1][j]; //deletion
dp[i][j]=min(q1,min(q2,q3))+(inp[i-1]!=out[i-1]);
}
}
return dp[m][n];
}

int main()
{
char inp[100],out[100];
cin>>inp>>out;
cout<<editDist(inp,out)<<endl;
return 0;
}

@meg.2198 hey Megha please next time save your code on ide.
dp[i][j]=min(q1,min(q2,q3))+(inp[i-1]!=out[i-1]);
the line should be
dp[i][j]=min(q1,min(q2,q3))+(inp[i-1]!=out[j-1]);

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.