A binary tree is height-balanced if, for every node, the heights of its left subtree and right subtree differ by at most 1. The height of a subtree is the number of levels in it.
Given a binary tree, return true if it is height-balanced, and false if it is not.
How the judge passes the data
Examples
Example 1:
Input: root = [5,3,8,2,null,7,9]
Output: true
Explanation: At every node the two sides differ in height by at most 1.
Example 2:
Input: root = [8,6,null,5]
Output: false
Explanation: The tree is a chain to the left. The root has a left height of 3 and a right height of 0.
Example 3:
Input: root = [7,7,7]
Output: true
Explanation: Both sides of the root have the same height.