Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 2800b6f

Browse files
committed
1080 wrong answer
1 parent ec54aad commit 2800b6f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths.go

+10
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,15 @@ func dfs(node *TreeNode, pre, limit int) int {
4444
max = r
4545
}
4646

47+
if max == math.MinInt64 {
48+
return node.Val
49+
}
4750
return max + node.Val
4851
}
52+
53+
func max(a, b int) int {
54+
if a > b {
55+
return a
56+
}
57+
return b
58+
}

Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ var tcs = []struct {
1414
ans []int
1515
}{
1616

17+
{
18+
[]int{1, 2, -3, -5, kit.NULL, 4, kit.NULL},
19+
-1,
20+
[]int{1, kit.NULL, -3, 4},
21+
},
22+
1723
{
1824
[]int{1, 2, 3, 4, -99, -99, 7, 8, 9, -99, -99, 12, 13, -99, 14},
1925
1,
@@ -26,16 +32,10 @@ var tcs = []struct {
2632
[]int{5, 4, 8, 11, kit.NULL, 17, 4, 7, kit.NULL, kit.NULL, kit.NULL, 5},
2733
},
2834

29-
{
30-
[]int{1, 2, -3, -5, kit.NULL, 4, kit.NULL},
31-
-1,
32-
[]int{1, kit.NULL, -3, 4},
33-
},
34-
3535
{
3636
[]int{1, 2, -3, -5, kit.NULL, 4, kit.NULL},
3737
100,
38-
nil,
38+
[]int{},
3939
},
4040

4141
// 可以有多个 testcase

0 commit comments

Comments
 (0)