class Solution {
private int preNodeValue = -1;
private int result = Integer.MAX_VALUE;
public int getMinimumDifference(TreeNode root) {
inorder(root);
return this.result;
}
private void inorder(TreeNode root) {
if (root == null) {
return;
}
inorder(root.left);
if (this.preNodeValue != -1) {
this.result = Integer.min(root.val - this.preNodeValue, this.result);
}
this.preNodeValue = root.val;
inorder(root.right);
}
}