FastPrepFastPrep
Problem Brief

Calculate Efficiency Score

OA

You are given an initial parentheses sequence represented by the string s, along with a Parentheses Perfection Kit containing different types of parentheses in the form of the string kitParentheses and their respective efficiency ratings in the efficiencyRatings array (both of size m). The EfficiencyScore of the original string s is initially 0. You can use any number of unused parentheses from the kit to create the final sequence, as long as the final sequence remains balanced.

The task is to determine the maximum possible EfficiencyScore that can be achieved for the resulting balanced sequence. Note: It is guaranteed that the sequence can be made balanced by adding zero or more parentheses from the kit.

1Example 1

Input
s = ")((", kitParentheses = ")(()))", m = 6, efficiencyRatings = [3, 4, 2, -4, -1, -3]
Output
TO-DO
Explanation

TO-DO: Add explanation for the example here.

Constraints

Limits and guarantees your solution can rely on.

  • 1 ≤ |s| < 2 * 105
  • 0 ≤ m < 2 * 105
  • -109 ≤ efficiencyRatings[i] ≤ 109
  • Both strings s and kitParentheses consist of opening and closing parentheses only
  • public int calculateEfficiencyScore(String s, String kitParentheses, int[] efficiencyRatings) {
      // write your code here
    }
    
    Input

    s

    ")(("

    kitParentheses

    ")(()))"

    m

    6

    efficiencyRatings

    [3, 4, 2, -4, -1, -3]

    Output

    TO-DO

    Sign in to submit your solution.