View on GitHub

leetcode-diaries

A journal to record the solution of the various Leetcode problems solved over the course of time.

Minimum Distance Between BST Nodes

Leetcode problem 783; Difficulty: Easy

Problem Statement

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

Constraints:

Example 1:

image

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

Output: 1

Example 2:

image

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

Output: 1

Submitted Solution

The implemented solution received the following rating on Leetcode:

image