less than 1 minute read

Given a string s representing a boolean expression containing operators "and" and "or", evaluate it and return the result. The expression may have parentheses, which should be evaluated first.

https://binarysearch.com/problems/Parse-Boolean-Expression

Examples

Example 1

Input

  • s = true and (false or true)

Output

  • answer = True

Example 2

Input

  • s = (false or false)

Output

  • answer = False

Solution

Categories:

Updated:

Leave a comment