diff --git a/problems/0110.平衡二叉树.md b/problems/0110.平衡二叉树.md index 9d43407a..313aeff2 100644 --- a/problems/0110.平衡二叉树.md +++ b/problems/0110.平衡二叉树.md @@ -614,8 +614,10 @@ var isBalanced = function(root) { if(node === null) return 0; // 3. 确定单层递归逻辑 let leftDepth = getDepth(node.left); //左子树高度 - let rightDepth = getDepth(node.right); //右子树高度 + // 当判定左子树不为平衡二叉树时,即可直接返回-1 if(leftDepth === -1) return -1; + let rightDepth = getDepth(node.right); //右子树高度 + // 当判定右子树不为平衡二叉树时,即可直接返回-1 if(rightDepth === -1) return -1; if(Math.abs(leftDepth - rightDepth) > 1) { return -1;