Skip to content

Commit 10a0d4a

Browse files
committed
Create README - LeetHub
1 parent 0720348 commit 10a0d4a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<h2><a href="https://leetcode.com/problems/parsing-a-boolean-expression">1106. Parsing A Boolean Expression</a></h2><h3>Hard</h3><hr><p>A <strong>boolean expression</strong> is an expression that evaluates to either <code>true</code> or <code>false</code>. It can be in one of the following shapes:</p>
2+
3+
<ul>
4+
<li><code>&#39;t&#39;</code> that evaluates to <code>true</code>.</li>
5+
<li><code>&#39;f&#39;</code> that evaluates to <code>false</code>.</li>
6+
<li><code>&#39;!(subExpr)&#39;</code> that evaluates to <strong>the logical NOT</strong> of the inner expression <code>subExpr</code>.</li>
7+
<li><code>&#39;&amp;(subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub>)&#39;</code> that evaluates to <strong>the logical AND</strong> of the inner expressions <code>subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub></code> where <code>n &gt;= 1</code>.</li>
8+
<li><code>&#39;|(subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub>)&#39;</code> that evaluates to <strong>the logical OR</strong> of the inner expressions <code>subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub></code> where <code>n &gt;= 1</code>.</li>
9+
</ul>
10+
11+
<p>Given a string <code>expression</code> that represents a <strong>boolean expression</strong>, return <em>the evaluation of that expression</em>.</p>
12+
13+
<p>It is <strong>guaranteed</strong> that the given expression is valid and follows the given rules.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong class="example">Example 1:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> expression = &quot;&amp;(|(f))&quot;
20+
<strong>Output:</strong> false
21+
<strong>Explanation:</strong>
22+
First, evaluate |(f) --&gt; f. The expression is now &quot;&amp;(f)&quot;.
23+
Then, evaluate &amp;(f) --&gt; f. The expression is now &quot;f&quot;.
24+
Finally, return false.
25+
</pre>
26+
27+
<p><strong class="example">Example 2:</strong></p>
28+
29+
<pre>
30+
<strong>Input:</strong> expression = &quot;|(f,f,f,t)&quot;
31+
<strong>Output:</strong> true
32+
<strong>Explanation:</strong> The evaluation of (false OR false OR false OR true) is true.
33+
</pre>
34+
35+
<p><strong class="example">Example 3:</strong></p>
36+
37+
<pre>
38+
<strong>Input:</strong> expression = &quot;!(&amp;(f,t))&quot;
39+
<strong>Output:</strong> true
40+
<strong>Explanation:</strong>
41+
First, evaluate &amp;(f,t) --&gt; (false AND true) --&gt; false --&gt; f. The expression is now &quot;!(f)&quot;.
42+
Then, evaluate !(f) --&gt; NOT false --&gt; true. We return true.
43+
</pre>
44+
45+
<p>&nbsp;</p>
46+
<p><strong>Constraints:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= expression.length &lt;= 2 * 10<sup>4</sup></code></li>
50+
<li>expression[i] is one following characters: <code>&#39;(&#39;</code>, <code>&#39;)&#39;</code>, <code>&#39;&amp;&#39;</code>, <code>&#39;|&#39;</code>, <code>&#39;!&#39;</code>, <code>&#39;t&#39;</code>, <code>&#39;f&#39;</code>, and <code>&#39;,&#39;</code>.</li>
51+
</ul>

0 commit comments

Comments
 (0)