Minimum Cost to Convert String II
Asked in the Interview stage.
Implement minimum_cost(source, target, original, changed, cost). Each rule converts an entire substring original[i] into changed[i] at cost cost[i]. Rules may be chained, and each source-to-target conversion must use non-overlapping consecutive substrings. Return the minimum total cost, or -1 if conversion is impossible.
The strings source and target have equal length. Each rule's original and changed strings have equal length.
def minimum_cost(source, target, original, changed, cost):