one_edit_away(s1, s2) that returns True if s1 and s2 differ by at most one single-character edit — an insertion, a deletion, or a replacement.s1 = 'pale', s2 = 'ple'
True
Deleting the 'a' from 'pale' gives 'ple'.
s1 = 'pales', s2 = 'pale'
True
One trailing character inserted/deleted.
s1 = 'pale', s2 = 'bale'
True
One character replaced ('p' -> 'b').
s1 = 'pale', s2 = 'bake'
False
Two characters differ, which is more than one edit.
If the length difference is more than 1, the answer is immediately False.
Equal lengths: count mismatched positions; at most 1 is OK.
Lengths differing by 1: walk both strings with two pointers, allowing exactly one skip in the longer string when a mismatch is hit.