Problem of the day
Both 'S' and 'K' contain only lowercase English characters.
K = "aabb" and S = "bbcc"
Now Ninja can do the following changes:
- Change ‘b’ to ‘c’ -> “aacc”
- Change ‘a’ to ‘b’ -> “bbcc”
Hence Ninja can give Mico the desired gift.
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test case follows.
The first line of each test case contains a string 'S'.
The next line of each test case contains a string 'K'.
For each test case, if Ninja can convert K into S, return “True” else return “False”.
You don’t need to take any input or print anything. This already has been taken care of. Just implement the function.
1 <= T <= 5
1 <= |K|, |S| <= 10^5
Time Limit: 1 second
2
aabcc
ccdaa
ninjas
coding
True
False
Test case 1:
Here K=ccdaa and S=aabcc. Here we can change K into S by following conversions
Change ‘d’ to ‘b’ -> ccbaa
Change ‘a’ to ‘e’ -> ccbee
Change ‘c’ to ‘a’ -> aabee
Change ‘e’ to ‘c’-> aabcc
Test case 2:
It is not possible to change K to S by any number of conversions.
2
code
dope
acbz
acbza
True
False