Minimum Cost to Transform String

Company: Test_1

Difficulty: medium

Problem Statement

Minimum Cost to Transform String You are given two strings s and t , both made of lowercase English letters. You may apply the following operation to s any number of times, including zero: Choose an index i with 0 <= i < L , where L is the length of the current string. Remove the character sitting at index i . Concatenate the remaining characters in order, keeping their relative order. The step costs i units. Note that the index is measured in the string as it stands at that moment , not in the original s , so removing a character makes every character to its right cheaper to remove afterwards. Determine the minimum total cost of a sequence of operations that turns s into t . If no sequence of operations can turn s into t , report -1 . Input Format Line 1: the string s . Line 2: the string t . Output Format Print a single integer - the minimum total cost, or -1 if the transformation is impossible. Constraints 1 <= |t| <= |s| <= 99000 s and t contain only lowercase Englis