Skip to content

Practice Evaluate Boolean Binary Tree

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2331
LeetCode Problem

Evaluate Boolean Binary Tree

Problem Statement

In the full binary tree, each node has either zero or two children. Leaf values 0 and 1 mean false and true. Internal value 2 means OR and 3 means AND. Recursively evaluate both children and apply the internal node's operator. Return the boolean value of the root.

Source: Evaluate Boolean Binary Tree on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
root = [2,1,3,null,null,0,1]
Output
true

# Example 2

Input
root = [0]
Output
false

Constraints

The number of nodes in the tree is in the range [1, 1000].
0 <= Node.val <= 3
Every node has either 0 or 2 children.
Leaf nodes have a value of 0 or 1.
Non-leaf nodes have a value of 2 or 3.

Related LeetCode Problems

Practice more problems similar to Evaluate Boolean Binary Tree.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.