← 返回 amazon 的题目列表Maximize Efficiency by Inserting Weighted Spare Parentheses
类型:online_judge
amazon
Question 1: Optimal Parentheses Matching
Given a sequence of parentheses string and a spare bracket set kitParentheses, each with a specific weight kitEfficiencyRating. You need to add some spare brackets to make the original sequence a valid parentheses sequence and calculate the maximum efficiency score for this sequence.
Input:
string: A string containing the original parentheses sequence, with a length between 1 and 500.
kitParentheses: A sequence of spare brackets with associated weights.
Output:
Return the maximum efficiency score of the valid parentheses sequence.
Example:
string = ")()"
kitParentheses = "(("
kitEfficiencyRating = [-1, 5]
Output: 6
Example
Input
)(
()(
-1,5,-3