@@ -0,0 +1,918 @@
+/**%09Given a binary tree, determine if it is height-balanced.%0A *%0A *%09For this problem, a height-balanced binary tree is defined as a binary tree %0A *%09in which the depth of the two subtrees of every node never differ by more than 1.%0A *%0A *%09Author: matao%0A *%0A */%0A%0Aclass TreeNode %7B%0A%09int val;%0A%09TreeNode left;%0A%09TreeNode right;%0A%09TreeNode(int x) %7B val = x; %7D%0A%7D%0A%0Apublic class BalancedBinaryTree %7B%0A%09public static boolean isBalanced(TreeNode root) %7B%0A%09%09if (root == null) %7B%0A%09%09%09return true;%0A%09%09%7D%0A%09%09if(Math.abs(maxDepth(root.left) - maxDepth(root.right)) %3E 1) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%0A%09%09return isBalanced(root.left) && isBalanced(root.right);%0A%09%7D%0A%0A%09public static int maxDepth(TreeNode root) %7B%0A%09%09if(root == null) %7B%0A%09%09%09return 0;%0A%09%09%7D%0A%0A%09%09int leftDepth = maxDepth(root.left);%0A%09%09int rightDepth = maxDepth(root.right);%0A%09%09return leftDepth + 1 %3E rightDepth + 1 ? leftDepth + 1 : rightDepth + 1;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09%0A%09%7D%0A%0A%7D

add Balanced Binary Tree solution