Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Minimum Distance Between BST Nodes

XPChallenge Points: 10
levelLevel: Easy

You are given the root of a Binary Search Tree (BST).

Your task is to return the minimum absolute difference between the values of any two distinct nodes in the BST.

Because a BST’s inorder traversal gives values in sorted order, the smallest difference will always occur between two consecutive values in that order.

Example 1:

Input: root = [4,2,6,1,3]

Output: 1

Example 2:

Input: root = [1,0,48,null,null,12,49]

Output: 1

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result