class Solution {
public:
bool ans=true;
bool isBalanced(TreeNode* root){
dfs(root);
return ans;
}
int dfs(TreeNode* root){
if(!root) return 0;
int lh=dfs(root->left);
int rh=dfs(root->right);
if(abs(lh-rh)>1) ans=false;
return max(lh,rh)+1;
}
};
08-06
1268
09-08
1096
09-13
995
09-20
639
09-26
617