class Solution {
int min=Integer.MAX_VALUE;
public int minDiffInBST(TreeNode root) {
getMin(root);
return min;
}
TreeNode lastnode;
/**
* @return the min
*/
public void getMin(TreeNode root) {
if(root==null){
return;
}
getMin(root.left);
if(lastnode!=null){
min=Math.min(min,root.val-lastnode.val);
}
lastnode=root;
getMin(root.right);
}
}