#C861. One-Edit Transformation
One-Edit Transformation
One-Edit Transformation
Given two strings s₁ and s₂, determine if s₁ can be transformed to s₂ by applying exactly one of the following operations:
- Insertion of a single character at any position.
- Deletion of a single character from any position.
- Replacement of a single character with another character.
Mathematically, if we let n₁ = length(s₁) and n₂ = length(s₂), then it must hold that \(|n₁ - n₂| \le 1\). In the case when \(n₁ = n₂\), there should be exactly one position where the characters differ.
Your task is to read the two input strings from standard input and print True
if the transformation is possible by exactly one operation, otherwise print False
.
inputFormat
The input consists of two lines:
- The first line contains the string s₁.
- The second line contains the string s₂.
outputFormat
Output a single line containing either True
or False
(without quotes) to indicate whether s₁ can be transformed into s₂ by exactly one edit operation.
cat
cats
True