Edit Distance 2D DP

Sir I am unable to understand why am I getting runtime error?

Hey @pangatt4
Please share your code in Coding Blocks IDE

Link to code, Edit Distance:

Hey @pangatt4

	if(i1 > l1)		
		return s2.length()-i2; //updated
	if(i2 > l2)		
		return s1.length()-i1;  //updated
1 Like

Okay, I understood that logic. But as I created dp[][] with dimention as largest of both strings, then also it gave segmentation fault. That should have worked, don’t know why?

Yeah wasn’t able to figure out the issue

try to dry run for

a
b