Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-343

Edit Distance One Substitution Check

Problem

Two strings of equal length are at substitution distance one when exactly one position differs.

Given the two strings, return True when the edit script is a single substitution.

Hint

Count mismatched positions with equal lengths.

Test cases

case 1
in: ["cat","cot"]
expected: true
case 2
in: ["cat","cat"]
expected: false
case 3
in: ["cat","dog"]
expected: false
Starter codePython
def edit_distance_one_substitution_check(a, b):
    # Your code here
    pass

3 test cases · run your code against them in the editor