mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			773 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			773 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给定一个布尔表达式和一个期望的布尔结果 result,布尔表达式由 <code>0</code> (false)、<code>1</code> (true)、<code>&</code> (AND)、 <code>|</code> (OR) 和 <code>^</code> (XOR) 符号组成。实现一个函数,算出有几种可使该表达式得出 result 值的括号方法。</p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "1^0|0|1", result = 0
 | 
						||
 | 
						||
<strong>输出:</strong>2
 | 
						||
<strong>解释:</strong>两种可能的括号方法是
 | 
						||
1^(0|(0|1))
 | 
						||
1^((0|0)|1)
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "0&0&0&1^1|0", result = 1
 | 
						||
 | 
						||
<strong>输出:</strong>10</pre>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li>运算符的数量不超过 19 个</li>
 | 
						||
</ul>
 |