Segmentation fault in EDIT DISTANCE

I was trying to solve this problem:

The code that I wrote (using memoization) is :

However, if I input strings abc and ab, I get segmentation fault. I tried debugging it on onlineGDB, but I am not sure why I get segmentation fault.

Please guide about why there is segmentation fault and send the corrected code

refer this https://ide.codingblocks.com/s/590108

Sir though the solution shared by you is working, can you please debug my code? I am not able to find out the mistake in my code.

so basically what we have to check is last 2 characters of the string and then recursively check for smaller strings… but u are doing opposite… thats why ur code is failing

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.