[LeetCode]Balanced Binary Tree
public class Solution { boolean result = true; public boolean isBalanced(TreeNode root) { helper(root); return result; } public int helper(TreeNode root) { if (root == null) { return 0; } int left = helper(root.left); int right = helper(root.right); if (Math.abs(left - right) > 1) { result = false; return -1; } else { return Math.max(left, right) + 1; } } }