#C4241. One Operation Transformation
One Operation Transformation
One Operation Transformation
You are given two strings s
and t
. Your task is to determine if you can transform s
into t
by performing exactly one of the following operations:
- Insertion: Insert a single character at any position in s.
- Deletion: Delete a single character from any position in s.
- Replacement: Replace a single character in s with another character.
If it is possible to obtain t
from s
with exactly one of these operations, print YES
. Otherwise, print NO
.
Note: The absolute difference in the lengths of the two strings must satisfy \(| |s| - |t| | \le 1\). In particular, if the two strings are equal, no operation is needed, so the answer is NO
.
inputFormat
The input consists of two lines:
- The first line contains the string
s
. - The second line contains the string
t
.
Both strings will consist of only printable characters and may be empty.
outputFormat
Output a single line containing YES
if t
can be formed from s
by exactly one operation (insertion, deletion, or replacement). Otherwise, output NO
.
abcd
abcde
YES
</p>