Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
Given two strings s
and t
, return True
if they are both one edit distance apart, otherwise return False
.
A string s
is said to be one distance apart from a string t
if you can:
s
to get t
s
to get t
s
with a different character to get t
Example 1:
Input: s = "ab", t = "acb"
Output: True
Explanation: We can insert 'c' into s to get t.
Example 2:
Input: s = "", t = ""
Output: False
Explanation: We cannot get t from s by only one step.
Example 3:
Input: s = "a", t = ""
Output: True
Example 4:
Input: s = "", t = "A"
Output: True
is_one_edit_distance
s
and t
Complete the below code in the right side coding panel
def is_one_edit_distance(s: str, t: str) -> bool:
# your code goes here
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...