Problem Description
Given a root of binary tree A, determine if it is height-balanced.
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.
1 <= size of tree <= 100000
First and only argument is the root of the tree A.
Return 0 / 1 ( 0 for false, 1 for true ) for this problem.
Input 1:
1 / \ 2 3
Input 2:
1 / 2 / 3
Output 1:
1
Output 2:
0
Explanation 1:
It is a complete binary tree.
Explanation 2:
Because for the root node, left subtree has depth 2 and right subtree has depth 0. Difference = 2 > 1.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.