Given a binary tree with n nodes, return TRUE if it is height-balancedA binary tree is considered height-balanced if the difference between the heights of the two subtrees for each node is not more than 1.. Otherwise, return FALSE.
Note: The height of an empty tree is 0.
Constraints:
1≤n≤500
−104≤Node.data≤104
Examples
1/ 3
Understand the problem
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Balanced Binary Tree
1.
Given the below binary tree, what is the output?
5
/ \
4 8
/ \
7 9
\
10
A.
TRUE
B.
FALSE
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence.
1
2
3
4
Try it yourself
Implement your solution in the following coding playground.
Given a binary tree with n nodes, return TRUE if it is height-balancedA binary tree is considered height-balanced if the difference between the heights of the two subtrees for each node is not more than 1.. Otherwise, return FALSE.
Note: The height of an empty tree is 0.
Constraints:
1≤n≤500
−104≤Node.data≤104
Examples
1/ 3
Understand the problem
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Balanced Binary Tree
1.
Given the below binary tree, what is the output?
5
/ \
4 8
/ \
7 9
\
10
A.
TRUE
B.
FALSE
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence.
1
2
3
4
Try it yourself
Implement your solution in the following coding playground.