Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.
Example 1
3
/ \
9 20
/ \
15 7Input
root = [3,9,20,null,null,15,7]Output
trueThe given tree is height-balanced, so the result is true.
Example 2
1
/ \
2 2
/ \
3 3
/ \
4 4Input
root = [1,2,2,3,3,null,null,4,4]Output
falseThe given tree is not height-balanced, so the result is false.
Constraints
- The number of nodes in the tree is in the range
[0, 5000]. -10^4 <= Node.val <= 10^4