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 (English)/布尔运算(English) [boolean-evaluation-lcci].html

26 lines
897 B
HTML

<p>Given a boolean expression consisting of the symbols <code>0</code> (false), <code>1</code> (true), <code>&amp;</code> (AND), <code>|</code> (OR), and <code>^</code>&nbsp;(XOR), and a desired boolean result value result, implement a function to count the number of ways of parenthesizing the expression such that it evaluates to result.</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input: </strong>s = &quot;1^0|0|1&quot;, result = 0
<strong>Output: </strong>2
<strong>Explanation:</strong>&nbsp;Two possible parenthesizing ways are:
1^(0|(0|1))
1^((0|0)|1)
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input: </strong>s = &quot;0&amp;0&amp;0&amp;1^1|0&quot;, result = 1
<strong>Output: </strong>10</pre>
<p><strong>Note: </strong></p>
<ul>
<li>There are no more than&nbsp;19 operators in <code>s</code>.</li>
</ul>