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 928a65c commit 3aebd28Copy full SHA for 3aebd28
Algorithms/0110.balanced-binary-tree/balanced-binary-tree.go
@@ -7,17 +7,17 @@ import (
7
type TreeNode = kit.TreeNode
8
9
func isBalanced(root *TreeNode) bool {
10
- _, isBalanced := cur(root)
+ _, isBalanced := recur(root)
11
return isBalanced
12
}
13
14
-func cur(root *TreeNode) (int, bool) {
+func recur(root *TreeNode) (int, bool) {
15
if root == nil {
16
return 0, true
17
18
19
- leftDepth, leftIsBalanced := cur(root.Left)
20
- rightDepth, rightIsBalanced := cur(root.Right)
+ leftDepth, leftIsBalanced := recur(root.Left)
+ rightDepth, rightIsBalanced := recur(root.Right)
21
22
if leftIsBalanced && rightIsBalanced &&
23
-1 <= leftDepth-rightDepth && leftDepth - rightDepth <= 1 {
0 commit comments