依据:平衡二叉树的左右子树高度差不超过1
private boolean isBalanced = true; public boolean isbalanced_solutions(TreeNode root) { height(root); return isBalanced; } private int height(TreeNode root) { if(null == root) { return 0; } int left = height(root.left); int right = height(root.right); if(Math.abs(left - right) > 1) { isBalanced = false; } return 1+ Math.max(left, right); }