标签:操作 节点 abs roo desc 剑指offer scribe return esc
public class Solution {//树 my public boolean IsBalanced_Solution(TreeNode root) { return help(root)!=-1;//-1表示不是二叉平衡树 } public int help(TreeNode root){ if(null==root){ return 0; } int left = help(root.left); if(-1==left){ return -1; } int right = help(root.right); if(-1==right||Math.abs(left-right)>1){ return -1; } return right>left?right+1:left+1; } }
标签:操作 节点 abs roo desc 剑指offer scribe return esc
原文地址:https://www.cnblogs.com/zhacai/p/10697410.html