Edit Distance

Hard

Edit Distance

Problem Statement: Given two strings

word1
and
word2
, compute the edit distance between them. The edit distance is the minimum number of operations (insertions, deletions, and substitutions) needed to convert
word1
into
word2
.

Rules and Constraints:

  • The edit operations allowed are insertion, deletion, and substitution.
  • You can use each type of operation any number of times.
  • The input strings
    word1
    and
    word2
    consist of lowercase English letters.
  • The length of both strings is at most 300 characters.
  • The time complexity of your solution should be O(n * m), where n and m are the lengths of
    word1
    and
    word2
    , respectively.
  • The space complexity of your solution should be O(n * m), where n and m are the lengths of
    word1
    and
    word2
    , respectively.

Input and Output:

  • Input: Two strings
    word1
    and
    word2
    .
  • Output: The edit distance between
    word1
    and
    word2
    .

This problem involves finding the minimum edit distance between two strings, which is a fundamental task in algorithmic design and has numerous applications in computer science, such as spell checking, DNA sequencing, and more. Your goal is to develop a solution that can efficiently compute the edit distance between two given strings.

Example

Input: {"input_data":[1,2,3]} Output: [1,2,3]

CompaniesGoogleMetaAmazon
JavaScript

Login to write code

Solve problems, verify your skills, and earn XP.