@@ -0,0 +1,1091 @@
+package leetcode;%0A%0A/**%0A * https://oj.leetcode.com/problems/balanced-binary-tree/%0A * %0A * Definition for binary tree%0A * public class TreeNode %7B%0A *     int val;%0A *     TreeNode left;%0A *     TreeNode right;%0A *     TreeNode(int x) %7B val = x; %7D%0A * %7D%0A */%0Apublic class Problem110 %7B%0A    public static class TreeNode %7B%0A        int val;%0A        TreeNode left;%0A        TreeNode right;%0A        TreeNode(int x) %7B val = x; %7D%0A    %7D%0A    %0A    public boolean isBalanced(TreeNode root) %7B%0A        if (root == null) %7B%0A            return true;%0A        %7D%0A        try %7B%0A            int left = getHeight(root.left);%0A            int right = getHeight(root.right);%0A            return (Math.abs(left - right) %3C= 1);%0A        %7D catch (Exception e) %7B%0A            return false;%0A        %7D%0A    %7D%0A    %0A    private int getHeight(TreeNode node) %7B%0A        if (node == null) %7B%0A            return 0;%0A        %7D%0A        int x = getHeight(node.left);%0A        int y = getHeight(node.right);%0A        if (Math.abs(x - y) %3C= 1) %7B%0A            return Math.max(x, y) + 1;%0A        %7D%0A        throw new RuntimeException(%22Not balanced%22);%0A    %7D%0A%7D%0A

Solve problem 110