#B3958. Check String Similarity
Check String Similarity
Check String Similarity
Given two strings \(A\) and \(B\), we say that they are similar if \(A\) can be transformed into \(B\) by performing exactly one of the following operations:
- Insertion: Insert exactly one character into \(A\).
- Deletion: Delete exactly one character from \(A\).
- Substitution: Modify exactly one character in \(A\).
In addition, two identical strings are also considered similar.
For example, the string apple
can be transformed into:
applee
by inserting one character,appe
by deleting one character, andbpple
by substituting one character.
Thus, apple
is similar to applee
, appe
, and bpple
. However, since applee
cannot be transformed into bpple
via any single operation, they are not similar.
You are given \(T\) test cases. For each test case, determine whether the two given strings are similar.
inputFormat
The first line contains an integer \(T\), the number of test cases.
For each test case, two lines follow. The first line contains string \(A\) and the second line contains string \(B\).
outputFormat
For each test case, print a single line: "Yes" if the two strings are similar, otherwise print "No".
sample
3
apple
applee
apple
appe
apple
bpple
Yes
Yes
Yes
</p>