```
class Solution {
public:
int getMinimumDifference(TreeNode* root) {
if (root == nullptr) {
return INT_MAX;
}
TreeNode* l = root->left;
TreeNode* r = root->right;
int ld = INT_MAX;
while (l != nullptr) {
ld = root->val - l->val;
l = l->right;
}
int rd = INT_MAX;
while (r != nullptr) {
rd = r->val - root->val;
r = r->left;
}
return min(min(ld, rd), min(getMinimumDifference(root->left), getMinimumDifference(root->right)));
}
};
```