Problem
Given a balanced string s of parentheses, compute its score with these rules:
- () scores 1.
- AB (two balanced strings side by side) scores A + B.
- (A) (a balanced string wrapped in brackets) scores 2 * A.
Example 1
- Input
- s = "()"
- Output
- 1
Example 2
- Input
- s = "(())"
- Output
- 2
Example 3
- Input
- s = "()()"
- Output
- 2
Example 4
- Input
- s = "(()(()))"
- Output
- 6
- Why
- 2 * (1 + 2)
Constraints
2 <= s.length <= 50s contains only ( and ).s is a balanced parentheses string.