We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 160ec6d commit 13a58eeCopy full SHA for 13a58ee
二叉树/平衡二叉树-110.js
@@ -0,0 +1,15 @@
1
+let isBalanced = function (root) {
2
+ if (!root) {
3
+ return true
4
+ }
5
+
6
+ let isSonBalnaced =
7
+ Math.abs(getHeight(root.left) - getHeight(root.right)) <= 1
8
9
+ return isSonBalnaced && isBalanced(root.left) && isBalanced(root.right)
10
+}
11
12
+function getHeight(node) {
13
+ if (!node) return 0
14
+ return Math.max(getHeight(node.left), getHeight(node.right)) + 1
15
0 commit comments