#K53827. One Swap String Transformation
One Swap String Transformation
One Swap String Transformation
Given two strings, determine whether the first string can be transformed into the second string by performing exactly one swap of any two characters. In other words, let D be the set of indices where the two strings differ. The transformation is possible if and only if ( |D| = 2 ) and, for the two indices ( i ) and ( j ) in D, swapping ( s1[i] ) and ( s1[j] ) results in ( s2 ), i.e., ( s1[i] = s2[j] ) and ( s1[j] = s2[i] ). Otherwise, the answer is "No".
inputFormat
The input is given via standard input (stdin) and consists of two lines. The first line contains the string s1 and the second line contains the string s2. It is guaranteed that both strings have the same length.
outputFormat
Output a single line to standard output (stdout) with either "Yes" or "No", indicating whether it is possible to transform s1 into s2 by performing exactly one swap of two characters.## sample
abcd
acbd
Yes