# Minimum Absolute Difference in BST (LeetCode 530) In-order walk of a BST yields sorted values; track previous and minimize `cur - prev`. ```python def getMinimumDifference(root): prev, best = None, float('inf') def dfs(n): nonlocal prev, best if not n: return dfs(n.left) if prev is not None: best = min(best, n.val - prev) prev = n.val dfs(n.right) dfs(root) return best ``` Say why sorting via stack also works. Try [AI interview copilot](https://www.linkjob.ai/interview-copilot/). (Affiliation: I work on Linkjob AI.)