WA - Edit distance (EDIST - SPOJ)

When a[i] == b[j] you don’t consider anything else.

if( a[i] == b[j] ) { dp[i][j] = dp[i-1][j-1] ; }
else{
dp[i][j] = min( dp[i-1][j-1], dp[i-1][j], dp[i][j-1] ) + 1
}

I got 50 as the answer on the test above once I fixed that.

1 Like