Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
Through each part of the solution, use recursion. Every node acts just like root. Be clear about the balanced conditions:
- Both left and right child nodes are balanced
- The height difference between the child nodes <= 1
So write another helper function to count the height. Use the same recursion idea to count the height for any node. For any node, the total height = larger child node height + 1.