BETA

Difficulty Level:

Easy

Total Submissions: 858 Accuracy:

27.27%

Minimum number of deletions and insertions.
     

Given two strings ‘str1’ and ‘str2’ of size m and n respectively. The task is to remove/delete and insert minimum number of characters from/in str1 so as to transform it into str2. It could be possible that the same character needs to be removed/deleted from one point of str1 and inserted to some another point.

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains integers N and M denoting the length of the strings str1 and str2. Both the strings consist of only small letter alphabets.

The second line of each test case contains the strings str1 and str2.


Output:

Print the total no of insertions and deletions to be done to convert str1 to str2. Output the answer in a new line.


Constraints:

1<= T <=100

1<= N, M <=1000


Example:

Input:

1

4 3

heap pea 

Output:

3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.