Dodomeki
Sign in

112. Edit Distance

Hard

Given the strings origem and destino, return the minimum number of operations needed to transform one into the other. An operation may insert, delete, or replace a character.

Example 1
Input: origem = "gato", destino = "rato"
Output: 1
Example 2
Input: origem = "sol", destino = "lua"
Output: 3
Constraints
  • 0 <= origem.length, destino.length <= 500
Dynamic programmingStrings
Caso 1
origem =
"gato"
destino =
"rato"
Expected =
1
Caso 2
origem =
"sol"
destino =
"lua"
Expected =
3

Run checks these 2 cases. Submit runs all 6, including hidden ones.