Weighted edit distance

Write codeMedium30 min

Your task

Compute a weighted edit distance between strings a and b where insert costs ci, delete costs cd, and substitute costs cs per single character (a matching character costs 0). Return the minimum total cost to transform a into b. Costs are positive integers; lengths up to ~1000.

Examples

weighted_edit_distance(a: str, b: str, ci: int, cd: int, cs: int) -> int
Example 1
Inputweighted_edit_distance("abc", "abd", 1, 1, 1)
Output1