Given the root of a binary tree, return true if the tree is height-balanced, or false otherwise.
A binary tree is height-balanced when, for every node, the heights of its left and right subtrees differ by no more than 1.
Input / output
root: TreeNode (JSON test fixture is a LeetCode-style level-order array using null for missing children, for example [3,9,20,null,null,15,7])booleanExamples
root = [3,9,20,null,null,15,7] returns true.root = [1,2,2,3,3,null,null,4,4] returns false.root = [] returns true because an empty tree is balanced.Constraints
0 <= number of nodes <= 5000-10^4 <= Node.val <= 10^4Follow-up Can you compute balance and height in the same postorder traversal so you never recompute subtree heights twice?