I am currently doing some coding in the break to be fresh ready for semester 2 at university.
I have encountered a CTCI problem which I am struggling to understand, I have also looked at the hints, but still am a bit clueless on how to approach it
The question
One Away: There are three types of edits that can be performed on strings: Insert a character, remove a character or replace a character. Given two strings write a function to check if they are one or zero edits away
Sample INPUT AND OUTPUT
- Input -> pale, ple Output-> true
- Input -> pales, pale Output -> true
- Input -> pale, bale Output -> true
- Input -> pale, bake Output -> false
PLEASE DO NOT GIVE ME THE SOLUTION I have read the hints, and still do not understand how I should approach this problem, I understand that in order for an insertion to be valid, the length of String word1 and word2 must have a difference of 1.
Can someone please give me some hints on where I should start, when completing this problem. Thank you.