Open youngyangyang04 opened 5 months ago
class Solution {
private List<Integer> list = new ArrayList<>();
public int getMinimumDifference(TreeNode root) {
inorderTraversal(root);
int res = list.get(1) - list.get(0);
for(int i = 2; i < list.size(); i++){
res = Math.min(list.get(i) - list.get(i - 1), res);
}
return res;
}
}
https://www.programmercarl.com/0530.%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E7%9A%84%E6%9C%80%E5%B0%8F%E7%BB%9D%E5%AF%B9%E5%B7%AE.html