示例#1
0
        private static int PostOrder(LeetCode563TreeNode root)
        {
            if (root == null)
            {
                return(0);
            }

            int left  = PostOrder(root.left);
            int right = PostOrder(root.right);

            ans += Math.Abs(left - right);

            return(root.val + left + right);
        }
示例#2
0
 public LeetCode563TreeNode(int val = 0, LeetCode563TreeNode left = null, LeetCode563TreeNode right = null)
 {
     this.val   = val;
     this.left  = left;
     this.right = right;
 }
示例#3
0
 public static int TiltSumInBST(LeetCode563TreeNode root)
 {
     PostOrder(root);
     return(ans);
 }