Minimum Absolute Difference in BST LeetCode solution in Python
1# Runtime: 46 ms (Top 97.4%) | Memory: 18.70 MB (Top 13.8%)234class Solution:5def getMinimumDifference(self, root: Optional[TreeNode]) -> int:6cur, stack, minDiff, prev = root, [], 10**5, -(10**5)78while stack or cur:9while cur:10stack.append(cur)11cur = cur.left12node = stack.pop()13minDiff = min(minDiff, node.val - prev)14prev = node.val15cur = node.right1617return minDiff