Problem of the day
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.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= str.length, ptr.length <= 100
Time limit: 1 sec
2
abcd anc
aa aaa
3
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.
2
cue dgo
edl xcqja
6
8