You are given 2 non-empty strings “str” and “ptr” consisting of lowercase English alphabets only. Your task is to convert string “str” into string “ptr”. In one operation you can do either of the following on “str”:
Remove a character from any position in “str”.
Add a character to any position in “str”.
You have to find the minimum number of operations required to convert string “str” into “ptr”.
For Example:
If str = “abcd”, ptr = “anc”
In one operation remove str[3], after this operation str becomes “abc”.
In the second operation remove str[1], after this operation str becomes “ac”.
In the third operation add ‘n’ in str[1], after this operation str becomes “anc”.
Hence, the output will be 3.
The first line of the input contains an integer, 'T’, denoting the number of test cases.
The first line of each test case will contain two space-separated non-empty strings “str” and “ptr”.
For each test case, print the minimum number of operations required to convert string “str” into “ptr”.
Print a separate line for each test case.
Note :
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 10
1 <= str.length, ptr.length <= 100
Time limit: 1 sec
Sample Input 1 :
2
abcd anc
aa aaa
Sample output 1 :
3
1
Explanation For Sample Output 1:
For the first test case,
str = “abcd”, ptr = “anc”
In one operation remove str[3], after this operation str becomes “abc”.
In the second operation remove str[1], after this operation str becomes “ac”.
In the third operation add ‘n’ in str[1], after this operation str becomes “anc”.
Hence, the output will be 3.
For the second test case,
str = “aaa”, ptr = “aa”
In one operation remove str[2], after this operation str becomes “aa”.
Hence, the output will be 1.
Sample Input 2 :
2
cue dgo
edl xcqja
Sample output 2 :
6
8