/
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode left;
* struct TreeNode right;
* };
*/
int max(int a,int b){return a>b?:a,b;}
int get(struct TreeNode root){
if(root == NULL)return 0;
return 1+max(get(root->left),get(root->right));
}
bool isBalanced(struct TreeNode root) {
if(root==NULL) return true;
int balance = get(root->left)-get(root->right);
if(balance <-1 || balance > 1)return false;
return isBalanced(root->left) && isBalanced(root->right);
}