Given a binary tree, determine if it is height-balanced.
A height-balanced binary tree is one in which the depth of the two subtrees of every node never differs by more than one.
Reason about the value returned from each subtree and the state passed down from ancestors. Empty children and single-node trees should be handled naturally.
Examples
Input: root = [3,9,20,null,null,15,7] Output: true
Input: root = [1,2,2,3,3,null,null,4,4] Output: false
Constraints
- The number of nodes is in the range [0, 5,000].
- -10,000 <= Node.val <= 10,000