Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Edit Distance Problem
00:00
5 left

Edit Distance Problem

HardPython

Problem

Edit Distance - calculate the minimum number of operations required to transform one string into another.

Asked in the Round 1 - online screening test stage. Second problem in the online screening test.

Implement def edit_distance(source, target):. Return the minimum number of single-character insertions, deletions, or substitutions required to transform source into target.

Input and Output

Both inputs are strings. Return an integer. A substitution costs one operation, including changing one character into another.

Constraints

  • 0 <= len(source) <= 1000
  • 0 <= len(target) <= 1000
  • Both strings contain only lowercase English letters

Function Signature

def edit_distance(source, target):
Interviewer

Your question is Edit Distance Problem. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.