Transform String
Submissions: 9707   Accuracy:

15.62%

  Difficulty: Medium   Marks: 4

You are provided two strings A and B. You have to transform string A into string B in minimum number of steps. Only one operation is allowed, chose any of the characters in string A and place it in the front of A. If its not possible to transform string A into string B then print -1 otherwise print the minimum number of steps required.

Note: All the characters in the string are lowercase English characters.

Input :

The first line contains integer T, denoting number of test cases. Then T test cases follow . 
The first line of each test case contains two space separated  strings A and B.

Output:
Print in a new line the answer of each test case .

Constraints :

1<=T<=100

1<=|A|,|B|<=10^5

Example:
Input:

2
bcad abcd
abdd dbad


Output :
1
2

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

Author: Sonesh Shukla


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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

to report an issue on this page.