1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/括号的分数 [score-of-parentheses].html
2022-03-29 12:43:11 +08:00

43 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个平衡括号字符串&nbsp;<code>S</code>,按下述规则计算该字符串的分数:</p>
<ul>
<li><code>()</code> 得 1 分。</li>
<li><code>AB</code>&nbsp;<code>A + B</code>&nbsp;分,其中 A 和 B 是平衡括号字符串。</li>
<li><code>(A)</code>&nbsp;<code>2 * A</code>&nbsp;分,其中 A 是平衡括号字符串。</li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入: </strong>&quot;()&quot;
<strong>输出: </strong>1
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入: </strong>&quot;(())&quot;
<strong>输出: </strong>2
</pre>
<p><strong>示例&nbsp;3</strong></p>
<pre><strong>输入: </strong>&quot;()()&quot;
<strong>输出: </strong>2
</pre>
<p><strong>示例&nbsp;4</strong></p>
<pre><strong>输入: </strong>&quot;(()(()))&quot;
<strong>输出: </strong>6
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ol>
<li><code>S</code>&nbsp;是平衡括号字符串,且只含有&nbsp;<code>(</code>&nbsp;&nbsp;<code>)</code>&nbsp;</li>
<li><code>2 &lt;= S.length &lt;= 50</code></li>
</ol>