1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-12 19:01:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

存量题库数据更新

This commit is contained in:
2023-12-09 18:42:21 +08:00
parent a788808cd7
commit c198538f10
10843 changed files with 288489 additions and 248355 deletions

View File

@@ -1,36 +1,43 @@
<p>一个只包含三种字符的字符串<code>&nbsp;</code><code></code>&nbsp;<code>*</code>,写一个函数来检验这个字符串是否为有效字符串有效字符串具有如下规则:</p>
<p>一个只包含三种字符的字符串,支持的字符类型分别是 <code>'('</code><code>')'</code> <code>'*'</code>。请你检验这个字符串是否为有效字符串,如果是有效字符串返回 <code>true</code></p>
<ol>
<li>任何左括号 <code>(</code>&nbsp;必须有相应的右括号 <code>)</code></li>
<li>任何右括号 <code>)</code>&nbsp;必须有相应的左括号 <code>(</code>&nbsp;</li>
<li>左括号 <code>(</code> 必须在对应的右括号之前 <code>)</code></li>
<li><code>*</code>&nbsp;可以被视为单个右括号 <code>)</code>&nbsp;,或单个左括号 <code>(</code>&nbsp;,或一个空字符串</li>
<p>有效字符串符合如下规则:</p>
<ul>
<li>任何左括号 <code>'('</code>&nbsp;必须有相应的右括号 <code>')'</code></li>
<li>任何右括号 <code>')'</code>&nbsp;必须有相应的左括号 <code>'('</code>&nbsp;</li>
<li>左括号 <code>'('</code> 必须在对应的右括号之前 <code>')'</code></li>
<li><code>'*'</code>&nbsp;可以被视为单个右括号 <code>')'</code>&nbsp;,或单个左括号 <code>'('</code>&nbsp;,或一个空字符串。</li>
<li>一个空字符串也被视为有效字符串。</li>
</ol>
</ul>
<p><strong>示例 1:</strong></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong> &quot;()&quot;
<strong>输出:</strong> True
<strong>输入</strong>s = "()"
<strong>输出</strong>true
</pre>
<p><strong>示例 2:</strong></p>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong> &quot;(*)&quot;
<strong>输出:</strong> True
<strong>输入</strong>s = "(*)"
<strong>输出</strong>true
</pre>
<p><strong>示例 3:</strong></p>
<p><strong class="example">示例 3</strong></p>
<pre>
<strong>输入:</strong> &quot;(*))&quot;
<strong>输出:</strong> True
<strong>输入</strong>s = "(*))"
<strong>输出</strong>true
</pre>
<p><strong>注意:</strong></p>
<p>&nbsp;</p>
<ol>
<li>字符串大小将在 [1100] 范围内。</li>
</ol>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 100</code></li>
<li><code>s[i]</code><code>'('</code><code>')'</code><code>'*'</code></li>
</ul>