标签:code color span 输入 solution root pre nod subject
1 public class Solution { 2 boolean flag = true; 3 public boolean IsBalanced_Solution(TreeNode root) { 4 if(root == null) return true; 5 6 getDepth(root); 7 8 return flag; 9 } 10 11 public int getDepth(TreeNode root){ 12 if(root == null) return 0; 13 int left = getDepth(root.left); 14 int right = getDepth(root.right); 15 int len = left - right; 16 17 if(Math.abs(len) > 1) flag = false; 18 19 return left > right ? left + 1 : right + 1; 20 } 21 }
标签:code color span 输入 solution root pre nod subject
原文地址:http://www.cnblogs.com/2390624885a/p/6708326.html