← 返回 apple 的题目列表One Edit Distance
类型:qbank
Given two strings s and t, return true if they are both exactly one edit distance apart, otherwise return false.
Examples
Example 1:
Input: s = "ab" t = "acb"
Output: true
Explanation:
Insert c into s between a and b to get t.
Example 2:
Input: s = "cab" t = "ad"
Output: false
Explanation:
These strings differ by more than one edit.
Example 3:
Input: s = "1203" t = "1213"
Output: true
Explanation:
Replace 0 in s with 1 to get t.
Example 4:
Input: s = "a" t = "a"
Output: false
Explanation:
Equal strings are zero edits apart, not one.
Constraints
0 <= s.length, t.length <= 10^4
s and t consist of lowercase letters, uppercase letters, and digits.