# 0110. Balanced Binary Tree ###### tags: `Leetcode` `Easy` `Tree` Link: https://leetcode.com/problems/balanced-binary-tree/ ## 思路 ## Code ```java= class Solution { public boolean isBalanced(TreeNode root) { if(root==null) return true; int left = computeHeight(root.left); int right = computeHeight(root.right); if(left==-1 || right==-1) return false; if(Math.abs(left-right)<=1) return true; else return false; } private int computeHeight(TreeNode root){ if(root==null) return 0; int left = computeHeight(root.left); int right = computeHeight(root.right); if(left==-1 || right==-1) return -1; if(Math.abs(left-right)>1) return -1; return Math.max(left, right)+1; } } ```