Skip to content

Commit 99280a3

Browse files
aQuaaQua
authored andcommitted
124 accepted. 632ms > 43ms
1 parent cc55bfb commit 99280a3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Algorithms/0124.binary-tree-maximum-path-sum/binary-tree-maximum-path-sum.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ func maxPathSum(root *TreeNode) int {
1515
max(0, maxSince(root.Left)) +
1616
max(0, maxSince(root.Right))
1717

18-
return max(sum,
19-
max(maxPathSum(root.Left), maxPathSum(root.Right)))
18+
return max(
19+
sum,
20+
max(
21+
maxPathSum(root.Left),
22+
maxPathSum(root.Right),
23+
),
24+
)
2025
}
2126

2227
// 返回,从 root 出发,包含 root 在内的所有可能路径的最大的 sum 值

0 commit comments

Comments
 (0)