One Edit Distance
Given two stringss andt, determine if they are both one edit distance apart.
Note:
There are 3 possiblities to satisfy one edit distance apart:
Insert a character into s to get t
Delete a character from s _to get t_
Replace a character of s to get t
Example
Example 1:
Example 2:
Example 3:
Note
当当前位置不一样的时候,根据三种情况分别比较substring
edge case 长度差一,最后多一位,最后判断一下
Code
Last updated