Given a balanced parentheses string S
, compute the score of the string based on the following rule:
<li><code>()</code> has score 1</li>
<li><code>AB</code> has score <code>A + B</code>, where A and B are balanced parentheses strings.</li>
<li><code>(A)</code> has score <code>2 * A</code>, where A is a balanced parentheses string.</li>
Example 1:
Input: "()" Output: 1
Example 2:
Input: "(())" Output: 2
Example 3:
Input: "()()" Output: 2
Example 4:
Input: "(()(()))" Output: 6
Note:
<li><code>S</code> is a balanced parentheses string, containing only <code>(</code> and <code>)</code>.</li>
<li><code>2 <= S.length <= 50</code></li>