```
public boolean isBalanced(TreeNode root) {
return helper(root, 0)>=0;
}
public int helper(TreeNode root, int count) {
if (root==null) {
return 0;
}
int countL = helper(root.left, count);
countL++;
int countR = helper(root.right, count);
countR++;
if (Math.abs(countL-countR)>1) return -10000; // lol, this solution will fxxked up if the tree has more than 10000 levels looooool
return (countL>=countR)?countL:countR;
}
```