DP- Edit Distance

Shouldn’t we make a hashmap in this question and then go through the keys, decrement the value if the key is present in both the strings and then in the end just sum up the values of the remaining keys. That should give us the total operations we need to perform isn’t it ?

Order of the keys also matter.
For eg.
abcd
bcfda

If you apply your method, you would just like to remove “f” which isn’t correct.
You need to completely transform string 1 to string 2.

I think I made a mistake there, now answer for that should be 2 right ?, what I was doing is
According to your example , assume you make a (ordered) map of <string,int> , it would be like
for string s1: a-1 b-1 c-1 d-1
for string s2: a-1 b-1 c-1 d-1 f-1
after comparison and decrement in the values
a-0 b-0 c-0 d-0 f-1
but that doesn’t get me the exact order of the string.
Got it

I hope I’ve cleared your doubt. I ask you to please rate your experience.
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.

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.