Boolean expression evaluator
A boolean expression is given as a string using the grammar: `t` (true), `f` (false), `!(expr)` (NOT), `&(e1,e2,...)` (AND of one or more sub-expressions), and `|(e1,e2,...)` (OR of one or more sub-expressions). Sub-expressions are comma-separated and may nest arbitrarily. Parse and evaluate the expression and return the resulting boolean. Assume the input is always well-formed.
Implement
parse_bool(expr: str) → boolExamples
in
["&(t,f)"]outfalseWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
["&(t,f)"]falsenot run yetsample