Easy Top Down && Bottom Up(beat 89.35%) Solutions in JAVA
Top Down Solution, which is O(n^2) time complexity\n\n    public boolean isBalanced(TreeNode root) {\n        if (root == null) return true;\n        if (root.l
Top Down Solution, which is O(n^2) time complexity\n\n    public boolean isBalanced(TreeNode root) {\n        if (root == null) return true;\n        if (root.left == null && root.right == null) return true;\n        int left = depth(root.left);\n        int right = depth(root.right);\n        return Math.abs(left-right) <=1 && isBalanced(root.left) && isBalanced(root.right);\n    }\n    public int depth(TreeNode root) {\n        if (root == null) return 0;\n        if (root.left == null && root.right == null) return 1;\n        return Math.max(depth(root.left),depth(root.right))+1;\n    }\n\nBottom Up Solution, which is O(n) time complexity\n\n    public boolean isBalanced(TreeNode root) {\n        if (root == null) return true;\n        int depth = depth(root);\n        if (depth == -1) return false;\n        else return true;\n    }\n    private int depth(TreeNode root) {\n        if (root == null) return 0;\n        int left = depth(root.left);\n        int right = depth(root.right);\n        if (left == -1 || right == -1 || Math.abs(left-right) > 1) return -1;\n        return Math.max(left,right)+1;\n    }
[]