mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-14 03:41:41 +08:00
add leetcode problem-cn part3
This commit is contained in:
42
算法题(国内版)/problem (Chinese)/括号的分数 [score-of-parentheses].html
Normal file
42
算法题(国内版)/problem (Chinese)/括号的分数 [score-of-parentheses].html
Normal file
@@ -0,0 +1,42 @@
|
||||
<p>给定一个平衡括号字符串 <code>S</code>,按下述规则计算该字符串的分数:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>()</code> 得 1 分。</li>
|
||||
<li><code>AB</code> 得 <code>A + B</code> 分,其中 A 和 B 是平衡括号字符串。</li>
|
||||
<li><code>(A)</code> 得 <code>2 * A</code> 分,其中 A 是平衡括号字符串。</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入: </strong>"()"
|
||||
<strong>输出: </strong>1
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入: </strong>"(())"
|
||||
<strong>输出: </strong>2
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre><strong>输入: </strong>"()()"
|
||||
<strong>输出: </strong>2
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 4:</strong></p>
|
||||
|
||||
<pre><strong>输入: </strong>"(()(()))"
|
||||
<strong>输出: </strong>6
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ol>
|
||||
<li><code>S</code> 是平衡括号字符串,且只含有 <code>(</code> 和 <code>)</code> 。</li>
|
||||
<li><code>2 <= S.length <= 50</code></li>
|
||||
</ol>
|
Reference in New Issue
Block a user