注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
能解释一下为什么第二个例子return val 是 6 不是8吗
Find Max To Balance
At Amazon, a user owns a unique tool called the "Parentheses Perfection Kit." This kit contains different types of parentheses, each with a specific efficiency rating. The goal is to create a balanced sequence of parentheses by adding zero or more parentheses from the kit to maximize the sequences total EfficiencyScore. The EfficiencyScore of a sequence is the sum of the efficiency ratings of the parentheses used from the kit.
A sequence is considered balanced if it has an equal number of opening '(' and closing ')' parentheses, with each opening parentheses properly matched with a closing oly, then the final balanced sequence will be "(0)" with a total EfficiencyScore of 4 + (-3) = 1. There are no other combinations of adding parentheses that can yield a balanced sequence with total EfficiencyScore greater than 1, Hence return 1 as answer.
Example 2:Input: s = "()", kitParentheses = ")(()))", efficiencyRatings = [3, 4, 2, -4, -1, -3]
Output: 6
Explanation:
:) |