说简单不简单 说难不难的困难题
class Solution {
    int maxAns = Integer.MIN_VALUE;
    public int maxPathSum(TreeNode root) {
        dfs(root);
        return maxAns;
    }
    public int dfs(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int left = Math.max(0, dfs(root.left));
        int right = Math.max(0, dfs(root.right));
        maxAns = Math.max(maxAns, root.val + left + right);
        return root.val + Math.max(left, right);
    }
}









