LeetCode知识点总结 – 783
LeetCode 783. Minimum Distance Between BST Nodes
考点难度TreeEasy
题目
Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree.
思路
和530题一样。
答案
class Solution {
int min = Integer.MAX_VALUE;
Integer prev = null;
public int minDiffInBST(TreeNode root) {
if (root == null) return min;
minDiffInBS
共有 0 条评论