class Solution {
public:
long ans = INT_MAX, last = INT_MIN;
void func(TreeNode* root) {
if (root == nullptr) {
return ;
}
func(root->left);
ans = min(ans, root->val - last);
last = root->val;
func(root->right);
}
int minDiffInBST(TreeNode* root) {
func(root);
return ans;
}
};