File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package main
3
3
4
4
import "math"
5
5
6
- type TreeBalance struct {
6
+ type treeBalance struct {
7
7
isBalanced bool
8
8
height int
9
9
}
@@ -12,13 +12,13 @@ func isBalanced(root *TreeNode) bool {
12
12
return checkBalance (root ).isBalanced
13
13
}
14
14
15
- func checkBalance (root * TreeNode ) * TreeBalance {
15
+ func checkBalance (root * TreeNode ) treeBalance {
16
16
if root == nil {
17
- return & TreeBalance {true , 0 }
17
+ return treeBalance {true , 0 }
18
18
}
19
19
left , right := checkBalance (root .Left ), checkBalance (root .Right )
20
20
isBalanced := left .isBalanced && right .isBalanced &&
21
21
math .Abs (float64 (left .height - right .height )) <= 1.0
22
22
height := max (left .height , right .height ) + 1
23
- return & TreeBalance {isBalanced , height }
23
+ return treeBalance {isBalanced , height }
24
24
}
You can’t perform that action at this time.
0 commit comments