Skip to main content
LeetCode 530, Easy. Topics: Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:

Problem

Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.

Examples

Example 1
Example 2

Constraints

  • The number of nodes in the tree is in the range [2, 10^4].
  • 0 <= Node.val <= 10^5
Note: This question is the same as 783: Minimum Distance Between BST Nodes.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026