LeetCode530. 二叉搜索树的最小绝对差
class Solution { int min = Integer.MAX_VALUE; TreeNode pre = null; public int getMinimumDifference(TreeNode root) { inOrder(root); return min; } private void inOrder(TreeNode root) { if (root == null) return; inOrder(root.left); if (pre != null) { min = Math.min(min, root.val - pre.val); } pre = root; inOrder(root.right); } }