Minimum Cost to Break a Subsequence Match

Asked at Amazon · Coding Questions · Difficulty: Medium

Some permutation of `password` contains `reference` as a subsequence exactly when `password`'s character counts dominate `reference`'s. Remove characters (removing one of character `c` costs `cost[c]`) so that no permutation of the remaining `password` contains `reference` as a subsequence. Return the minimum total cost.

Loading the problem…