shlogg · Early preview
Md Ariful Haque @mah-shamim

Parsing Boolean Expressions In PHP: Evaluating Logical Operations

Evaluates boolean expressions recursively using stack and helper functions for AND, OR, NOT operations.

1106. Parsing A Boolean Expression
Difficulty: Hard
Topics: String, Stack, Recursion
A boolean expression is an expression that evaluates to either true or false. It can be in one of the following shapes:

't' that evaluates to true.
'f' that evaluates to false.
'!(subExpr)' that evaluates to the logical NOT of the inner expression subExpr.
'&(subExpr1, subExpr2, ..., subExprn)' that evaluates to the logical AND of the inner expressions subExpr1, subExpr2, ..., subExprn where n >= 1.
'|(subExpr1, subExpr2, ..., subExprn)' that evaluates to the logical OR of the inner expressions subExpr1, subE...