One edit away
HardLet's say you're given two strings
a
and b
.Write a function that determines if the strings are one or zero edits away from eachother.
Consider a single edit as one of the following:
- An inserted character
- A replaced character
- A removed character
For example, given the two strings:
a = "car"b = "bar"
Your function should return
True
, since there is only one character replaced.Another example:
a = 'baby'b = 'babies'
Your function should return
False
since a
and b
are more than 1 edit away from eachother.Try it first
Solution
6 Essential Strings Coding Interview Problems
Master Strings by trying the coding challenges below.
- 1.Reverse StringEasy
- 2.AnagramEasy
- 3.Reverse wordsMedium
- 4.String matchMedium
- 5.CompressionMedium
- 6.One edit awayHard