# Minimum Absolute Difference in BST (Leetcode 530)

Problem Link: <https://leetcode.com/problems/minimum-absolute-difference-in-bst/>

```python
class Solution:
    def getMinimumDifference(self, root: Optional[TreeNode]) -> int:
        global ans,prev
        ans=float('inf')
        prev=float('-inf')
        
        def fun(root):
            global ans
            global prev
            if(root is None):
                return None
            fun(root.left)
            ans=min(ans,root.val-prev)
            prev=root.val
            fun(root.right)
        
        fun(root)
        return ans
```
