Problem Statement On Binary Tree
Problem Statement On Binary Tree
You are given the root of a binary tree that consists of exactly 3 nodes:
the root, its left child, and its right child.
Return true if the value of the root is equal to the sum of the values of its
two children, or false otherwise.
Example 1:
Constraints:
The tree consists only of the root, its left child, and its right child.
-100 <= Node.val <= 100
__________________________________________________________
Problem Statement 2:
Given the root of a binary tree, return the preorder traversal of its nodes'
values.
Example 1:
Input: root = [1,null,2,3]
Output: [1,2,3]
Example 2:
Input: root = []
Output: []
Example 3:
Input: root = [1]
Output: [1]
Constraints:
__________________________________________________________
Problem Statement 3:
You are given the root of a full binary tree with the following properties:
Leaf nodes have either the value 0 or 1, where 0 represents False and 1
represents True.
Non-leaf nodes have either the value 2 or 3, where 2 represents the
boolean OR and 3 represents the boolean AND.
The evaluation of a node is as follows:
If the node is a leaf node, the evaluation is the value of the node, i.e.
True or False.
Otherwise, evaluate the node's two children and apply the boolean
operation of its value with the children's evaluations.
Return the boolean result of evaluating the root node.
A full binary tree is a binary tree where each node has either 0 or 2
children.
Example 1:
Constraints:
Problem Statement 4:
Imagine that when you put one of them to cover the other, some nodes
of the two trees are overlapped while the others are not. You need to
merge the two trees into a new binary tree. The merge rule is that if two
nodes overlap, then sum node values up as the new value of the merged
node. Otherwise, the NOT null node will be used as the node of the new
tree.
Note: The merging process must start from the root nodes of both trees.
Example 1:
Constraints:
Problem Statement 5:
Given the root of a binary tree, invert the tree, and return its root.
Example 1:
Input: root = []
Output: []
Constraints:
Problem Statement 6:
Given the root of a binary tree, return the inorder traversal of its nodes'
values.
Example 1:
Input: root = [1,null,2,3]
Output: [1,3,2]
Example 2:
Input: root = []
Output: []
Example 3:
Constraints: