Score of Parentheses Problem
Score of Parentheses Problem — ExecCode Easy DSA Practice
Solve the Score of Parentheses problem on ExecCode. Free online easy DSA practice in Stack. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a balanced parentheses string s, return the score of the string. Your task is to the score of a balanced parentheses string is based on the following rule: - "()" has score 1. AB has score A + B, where A and B are balanced parentheses strings. - (A) has score 2 A, where A is a balanced parentheses string. Return the required answer exactly as shown in the examples.
Examples
Input {"s": "(()())"}; Output 4. Input {"s": "(()(()))"}; Output 6. Input {"s": "()"}; Output 1
Constraints
2 <= s.length <= 50 s consists of only '(' and ')'. s is a balanced parentheses string.
Practice Score of Parentheses free on ExecCode. Browse DSA problems, topic map, and placement guides.