标签:false turn || == color 剑指offer solution max 题目
public class Solution { public boolean IsBalanced_Solution(TreeNode root) { if(root==null) return true; int depthleft = TreeDepth(root.left); int depthright = TreeDepth(root.right); int cw = depthleft-depthright; if(cw<-1 || cw>1) return false; return IsBalanced_Solution(root.left)&&IsBalanced_Solution(root.right); } public int TreeDepth(TreeNode root) { if(root==null) return 0; int nleft = TreeDepth(root.left); int nright = TreeDepth(root.right); return Math.max(nleft,nright)+1; } }
标签:false turn || == color 剑指offer solution max 题目
原文地址:https://www.cnblogs.com/loyolh/p/12569304.html