Transform String
Submissions: 10039   Accuracy:


  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.

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

Constraints :




bcad abcd
abdd dbad

Output :

** 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, generate link and share the link here.

to report an issue on this page.