Given a balanced parentheses string S, compute the score of the string based on the rule: "()" has score 1, AB has score A + B, and (A) has score 2 * A, where A and B are balanced parentheses strings.
s = balanced parentheses string
score of the string
Example 1:
Input:
s = "()"
Output:
1
Explanation:
"()" has score 1.
Example 2:
Input:
s = "(())"
Output:
2
Explanation:
"(())" has score 2.
Example 3:
Input:
s = "()()"
Output:
2
Explanation:
"()()" has score 1 + 1 = 2.
Example 4:
Input:
s = "(()(()))"
Output:
6
Explanation:
"(()(()))" has score 2 * (1 + 2) = 6.