mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个只包含三种字符的字符串,支持的字符类型分别是 <code>'('</code>、<code>')'</code> 和 <code>'*'</code>。请你检验这个字符串是否为有效字符串,如果是 <strong>有效</strong> 字符串返回 <code>true</code> 。</p>
 | 
						||
 | 
						||
<p><strong>有效</strong> 字符串符合如下规则:</p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li>任何左括号 <code>'('</code> 必须有相应的右括号 <code>')'</code>。</li>
 | 
						||
	<li>任何右括号 <code>')'</code> 必须有相应的左括号 <code>'('</code> 。</li>
 | 
						||
	<li>左括号 <code>'('</code> 必须在对应的右括号之前 <code>')'</code>。</li>
 | 
						||
	<li><code>'*'</code> 可以被视为单个右括号 <code>')'</code> ,或单个左括号 <code>'('</code> ,或一个空字符串 <code>""</code>。</li>
 | 
						||
</ul>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong class="example">示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "()"
 | 
						||
<strong>输出:</strong>true
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong class="example">示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "(*)"
 | 
						||
<strong>输出:</strong>true
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong class="example">示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "(*))"
 | 
						||
<strong>输出:</strong>true
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= s.length <= 100</code></li>
 | 
						||
	<li><code>s[i]</code> 为 <code>'('</code>、<code>')'</code> 或 <code>'*'</code></li>
 | 
						||
</ul>
 |