first and second. An edit is one of these operations on first:
- insert one character anywhere;
- delete one character;
- replace one character with a *different* one.
Return true if second can be obtained from first with exactly one edit, and false otherwise. In particular, equal strings give false.first="plan", second="plain" → True
Insert i between a and n and you get exactly second.
first="Code", second="code" → True
One replacement: C becomes c. Case matters.
first="x7", second="x7" → False
The strings are already equal, but exactly one edit is required, so the answer is false.
first="plan", second="plain"
True
Run checks the first 3 tests in your browser. Submit checks all 177 tests on the server, hidden ones included.