Skip to content

Commit 87e5dcb

Browse files
committed
Create README - LeetHub
1 parent 3394b9b commit 87e5dcb

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h2><a href="https://leetcode.com/problems/parsing-a-boolean-expression/">1106. Parsing A Boolean Expression</a></h2><h3>Hard</h3><hr><div><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>'t'</code> that evaluates to <code>true</code>.</li>
5+
<li><code>'f'</code> that evaluates to <code>false</code>.</li>
6+
<li><code>'!(subExpr)'</code> that evaluates to <strong>the logical NOT</strong> of the inner expression <code>subExpr</code>.</li>
7+
<li><code>'&amp;(subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub>)'</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>'|(subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub>)'</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><strong>Input:</strong> expression = "&amp;(|(f))"
19+
<strong>Output:</strong> false
20+
<strong>Explanation:</strong>
21+
First, evaluate |(f) --&gt; f. The expression is now "&amp;(f)".
22+
Then, evaluate &amp;(f) --&gt; f. The expression is now "f".
23+
Finally, return false.
24+
</pre>
25+
26+
<p><strong class="example">Example 2:</strong></p>
27+
28+
<pre><strong>Input:</strong> expression = "|(f,f,f,t)"
29+
<strong>Output:</strong> true
30+
<strong>Explanation:</strong> The evaluation of (false OR false OR false OR true) is true.
31+
</pre>
32+
33+
<p><strong class="example">Example 3:</strong></p>
34+
35+
<pre><strong>Input:</strong> expression = "!(&amp;(f,t))"
36+
<strong>Output:</strong> true
37+
<strong>Explanation:</strong>
38+
First, evaluate &amp;(f,t) --&gt; (false AND true) --&gt; false --&gt; f. The expression is now "!(f)".
39+
Then, evaluate !(f) --&gt; NOT false --&gt; true. We return true.
40+
</pre>
41+
42+
<p>&nbsp;</p>
43+
<p><strong>Constraints:</strong></p>
44+
45+
<ul>
46+
<li><code>1 &lt;= expression.length &lt;= 2 * 10<sup>4</sup></code></li>
47+
<li>expression[i] is one following characters: <code>'('</code>, <code>')'</code>, <code>'&amp;'</code>, <code>'|'</code>, <code>'!'</code>, <code>'t'</code>, <code>'f'</code>, and <code>','</code>.</li>
48+
</ul>
49+
</div>

0 commit comments

Comments
 (0)