Beispiel #1
0
        private static void Helper(LeetCode530TreeNode root)
        {
            if (root == null)
            {
                return;
            }

            Helper(root.left);
            if (pre != int.MinValue)
            {
                ans = Math.Min(ans, root.val - pre);
            }
            pre = root.val;
            Helper(root.right);
        }
Beispiel #2
0
 public LeetCode530TreeNode(int val = 0, LeetCode530TreeNode left = null, LeetCode530TreeNode right = null)
 {
     this.val   = val;
     this.left  = left;
     this.right = right;
 }
Beispiel #3
0
        public static int GetMinimumDifference(LeetCode530TreeNode root)
        {
            Helper(root);

            return(ans);
        }