We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接
一棵高度平衡二叉树定义为:一个二叉树每个节点的左右两个子树的高度差的绝对值不超过 1。
const isBalanced = function(root) { if (!root) return true if (Math.abs(getHeight(root.left) - getHeight(root.right)) > 1) { return false } return isBalanced(root.left) && isBalanced(root.right) function getHeight (root) { if (!root) return 0 return Math.max(getHeight(root.left), getHeight(root.right)) + 1 } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接
一棵高度平衡二叉树定义为:一个二叉树每个节点的左右两个子树的高度差的绝对值不超过 1。
The text was updated successfully, but these errors were encountered: