https://leetcode.com/problems/balanced-binary-tree


Runtime: 1 ms, faster than 51.05% of Java online submissions for Balanced Binary Tree.
Memory Usage: 39.2 MB, less than 49.59% of Java online submissions for Balanced Binary Tree.



```java
class Solution {
    int max_level;

    void count(TreeNode node, int counting) {
        if (node != null) {
            counting += 1;
            if (counting > max_level) {
                max_level = counting;
            }
            count(node.left,counting);
            count(node.right,counting);
        }
    }

    boolean travel(TreeNode node) {
        if (node != null) {
            max_level = 0;
            count(node.left, 0);
            int a = max_level;

            max_level = 0;
            count(node.right, 0);
            int b = max_level;

            if (((a-b) > 1) || ((b-a) > 1)) {
                return false;
            }

            return travel(node.left) && travel(node.right); 
        } else {
            return true;
        }
    }

    public boolean isBalanced(TreeNode root) {
        //7:47
        return travel(root);
        //7:52
    }
}
```