Skip to content

Commit cea1ba9

Browse files
committed
feat: 0110.Balanced-Binary-Tree
1 parent 780bc37 commit cea1ba9

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Leetcode/0110.Balanced-Binary-Tree/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ func IsBalanced(root *TreeNode) bool {
139139
leftHight := depth(root.Left)
140140
rightHight := depth(root.Right)
141141

142-
// return abs(leftHight-rightHight) <= 1
143142
return abs(leftHight-rightHight) <= 1 && IsBalanced(root.Left) && IsBalanced(root.Right)
144143
}
145144

Leetcode/0110.Balanced-Binary-Tree/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func IsBalanced(root *TreeNode) bool {
2323
leftHight := depth(root.Left)
2424
rightHight := depth(root.Right)
2525

26-
// return abs(leftHight-rightHight) <= 1
2726
return abs(leftHight-rightHight) <= 1 && IsBalanced(root.Left) && IsBalanced(root.Right)
2827
}
2928

Leetcode/0110.Balanced-Binary-Tree/main_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ var tests = []struct {
1313
[]int{1, 2, 2, 3, structures.NULL, structures.NULL, 3, 4, structures.NULL, structures.NULL, 4},
1414
false,
1515
},
16+
{
17+
[]int{1, 2, 2, 3, structures.NULL, structures.NULL, 3, 4, structures.NULL, structures.NULL, 4},
18+
false,
19+
},
20+
{
21+
[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7},
22+
true,
23+
},
1624
}
1725

1826
func TestIsBalanced(t *testing.T) {

0 commit comments

Comments
 (0)