#C11134. One-Swap String Match
One-Swap String Match
One-Swap String Match
You are given two strings s1 and s2. Your task is to determine if you can make s1 equal to s2 by swapping exactly one pair of characters in s1.
The swap must be done exactly once and only on s1. If it is possible to make s1 equal to s2 with such a swap, output Yes. Otherwise, output No.
Note: Swapping the same positions or performing no swap is not allowed. Also, if the strings are already equal, the answer should be No since no swap is performed.
Formally, let the two strings be $s_1$ and $s_2$. If there exist exactly two distinct indices $i$ and $j$ (with $i \neq j$) such that swapping $s_1[i]$ and $s_1[j]$ makes $s_1 = s_2$, then output "Yes"; otherwise, output "No".
inputFormat
The input consists of two lines. The first line contains the string s1 and the second line contains the string s2.
Both strings will contain only printable ASCII characters and their lengths will be between 0 and 100 (inclusive).
outputFormat
Output a single line: Yes
if it's possible to make s1 equal to s2 by swapping exactly one pair of characters in s1, otherwise output No
.
ab
ba
Yes
</p>