Here is a solution provided to the twin strings problem.
Two strings, a and b, are said to be twins only if they can be made equivalent by performing some number of operations on one or both strings. There are two possible operations:
For example, a = "abcd" and b = "cdab" are twins because we can make them equivalent by performing operations. Alternatively, a = "abcd" and b = "bcda" are not twins (operations do not move characters between odd and even indices), and neither are a = "abc" and b = "ab" (no amount of operations will insert a 'c' into string b).
Complete the twins function in the provided code. It has two parameters:
The function must return an array of strings where each index i (0 ≤ i < n) contains the string Yes if ai and bi are twins or the string No if they are not.
Input Format
The provided code reads the following input from stdin and passes it to the function: The first line contains an integer, n, denoting the number of elements in a. Each line i of the n subsequent lines (where 0 ≤ i < n) contains a string describing ai. The next line contains an integer, n, denoting the number of elements in b. Each line i of the n subsequent lines (where 0 ≤ i < n) contains a string describing bi.
Constraints
Output Format
The function must return an array of strings where each index i (0 ≤ i < n) contains the string Yes if ai and bi are twins or the string No if they are not.
Sample Input 0
2 cdab dcba 2 abcd abcd
Sample Output 0
Yes No
Explanation 0
Given a = ["cdab", "dcba"] and b = ["abcd", "abcd"], we process each element like so: