48: Balanced binary tree
Given a binary tree
, write a method to check if the tree balanced
Note: a
height-balanced
binary tree is a binary tree in which thedepth
of the two subtrees ofeach node
does not differ by more thanone
Example 1
Input: 1
/ \
2 3 <-- difference = 2
/ /
4 5
/
6
Output: false
Example 2
Input: 1
/ \
5 3
Output: true