← 返回 amazon 的题目列表Minimum Cost to Remove Characters from Password
类型:online_judge
Given a string password and a string reference, along with an integer array costs of length 26, where each element represents the cost of removing a character 'a' to 'z'. Write a function to compute the minimum cost to remove some characters from password such that no permutation of password contains reference.
password and reference only contain lowercase letters.
len(password) <= 100
len(reference) <= 10
1 <= costs[i] <= 1000
Example 1:
Input: password = "abc", reference = "ab", costs = [1,1,1,...] Output: 0
Example 2:
Input: password = "aabbccd", reference = "abc", costs = [1,2,3,...] Output: 3
Example
Input
"abc", "ab", [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]