Skip to interview prep
Apexed
Problem list111 / 125

111. Edit Distance

HardDynamic programming

Return the minimum number of single-character inserts, deletes or replacements needed to turn a into b.

Example 1

Input: a = "horse", b = "ros"
Output: 3

Example 2

Input: a = "intention", b = "execution"
Output: 5

Constraints

  • 0 ≤ a.length, b.length ≤ 500

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Edit Distance — coding interview practice — Apexed