Edit distance

Medium · 2-D dynamic programming · Original CodeClash problem

Input is [a,b], strings. Return minimum insertions, deletions or substitutions to transform a into b.

Input and output

One JSON value on a single line, with the fields described above. Read it using json.loads(input()).

One compact JSON value. Use print(json.dumps(answer, separators=(",", ":"))). Booleans must be JSON true/false. Arrays retain the stated order.

Examples

Example 1

Input: ["level","lvl"]
Output: 2

Example 2

Input: ["abc","cba"]
Output: 2

Constraints

Solve in Python

Sign in to save progress. Public example runs are unverified and do not affect ratings.