783. Minimum Distance Between BST Nodes
题目描述
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.
Example :
|
|
Note:
- The size of the BST will be between 2 and 100.
- The BST is always valid, each node’s value is an integer, and each node’s value is different.
题目大意
给定一个二叉搜索树,返回树中任意两个不同节点的最小差值。
解题思路
中序遍历树,计算最小差值。
代码
|
|