530.二叉搜索树的最小绝对差
题目链接/文章讲解:代码随想录
视频讲解:二叉搜索树中,需要掌握如何双指针遍历!| LeetCode:530.二叉搜索树的最小绝对差_哔哩哔哩_bilibili
(1)代码
--New
501.二叉搜索树中的众数
视频讲解:不仅双指针,还有代码技巧可以惊艳到你! | LeetCode:501.二叉搜索树中的众数_哔哩哔哩_bilibili
(1)代码
--New
236. 二叉树的最近公共祖先
(1)代码
--New
其他补充
-
Integer.MAX_VALUE; //int最大值
Integer.MIN_VALUE; //int最小值
-
result=Math.min(result,cur.val-pre.val); //求两个值中的最小值
-
ArrayList<Integer> result=new ArrayList<>(); //ArrayList到int数组的转化
int[] res=new int[result.size()];
for(int i=0;i<result.size();i++){
res[i]=result.get(i);
}
-
ArrayList的属性
result.size(); //大小
result.get(i); //获取下标i的元素值
result.add(cur.val); //添加元素
result.clear(); //清空