#K42842. Transform String with One Swap
Transform String with One Swap
Transform String with One Swap
Given two strings (A) and (B), determine if it is possible to transform (A) into (B) by performing exactly one swap operation. A swap operation consists of choosing two distinct indices (i) and (j) in string (A) and exchanging the characters at those positions. Formally, if (A = a_1a_2 \ldots a_n) and (B = b_1b_2 \ldots b_n), you need to decide if there exist indices (i) and (j) such that swapping (a_i) and (a_j) results in (B).
Output "YES" if such a swap is possible, and "NO" otherwise.
inputFormat
The input is given via standard input (stdin) and consists of two lines. The first line contains the string (A) and the second line contains the string (B). Both strings are composed of lowercase English letters.
outputFormat
Print a single line to standard output (stdout): "YES" if string (A) can be transformed into string (B) with exactly one swap operation, and "NO" otherwise.## sample
abcd
abdc
YES