Determine a one-step string transformation
Company: Jerry.Ai
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
Quick Answer: This question evaluates proficiency in string manipulation and algorithmic reasoning, focusing on edit operations, positional changes, and edge-case handling.
Constraints
- source and target are lowercase strings.
- Return no_change if the strings are already equal.
- When several operations could work, this grader prefers add/delete, then replace, then the first left-to-right move.
Examples
Input: ('baren', 'bbren')
Expected Output: 'replace a b'
Explanation: One replacement changes a to b.
Input: ('banan', 'banana')
Expected Output: 'add a'
Explanation: One insertion adds the final a.
Input: ('abcde', 'acdeb')
Expected Output: 'move b'
Explanation: Moving b to the end transforms the source.
Input: ('banana', 'banan')
Expected Output: 'delete a'
Explanation: One deletion removes an a.
Input: ('abc', 'axcy')
Expected Output: 'impossible'
Explanation: No allowed single operation can transform the string.
Input: ('same', 'same')
Expected Output: 'no_change'
Explanation: Identical strings need no change.
Hints
- Length difference determines add and delete cases.
- For equal lengths, check replacement before testing moves.