Binary Tree Maximum Path Sum II
Question
分析
public int maxPathSum2(TreeNode root) {
if(root == null)
return 0;
int left = maxPathSum2(root.left);
int right = maxPathSum2(root.right);
return root.val + Math.max(0, Math.max(left, right));
}PreviousLowest Common Ancestor of a Binary Search TreeNextBinary Tree Level Order Traversal(dfs,bfs,python)
Last updated