Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Linked List Difference Function

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Linked List Difference Function. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Accretive Technology Group tools may need to compare revisions of configuration or content text. Given two strings, return the minimum number of single-character edits required to transform the first string into the second.

An edit is one of the following operations:

  1. Insert one character.
  2. Delete one character.
  3. Replace one character with another.

Formal Specification

Implement edit_distance(source, target).

  • Input: Two strings, source and target, containing lowercase English letters.
  • Output: An integer representing the minimum number of edits needed to transform source into target.
  • Each operation costs exactly 1.
  • Characters may be inserted, deleted, or replaced in any position.

Constraints

  • 0 <= len(source), len(target) <= 500
  • Strings contain only lowercase English letters
  • Each insertion, deletion, or replacement costs exactly 1

Function Signature

def edit_distance(source, target):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output