Single Mutation
We'll determine how to tell if two different strings are similar or extremely different. We'll also cover the idea of the double-condition loop, another tool to add to our repertoire.
We'll cover the following
Single Mutation
Instructions
There are 3 types of possible string mutations: character insertion, character deletion, or character substitution. Write a function that accepts 2 strings and returns true
if the strings are the same except for 0 or 1 mutations. Return false
otherwise.
Inputs: String, String
Output: Boolean
Examples:
-
Single Deletion:
'abcd'
,'abc'
'abcd'
,'acd'
-
Single Insertion:
'abcd'
,'abcde'
'abcd'
,'abXcd'
-
Single Substitution:
'abcd'
,'abXd'
'abcd'
,'Xbcd'
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.