摘要:
二叉树part6 530. 二叉搜索树的最小绝对差 - 力扣(LeetCode) 因为二叉搜索树BST中序遍历是升序序列,所以利用这个性质 class Solution { int diff = Integer.MAX_VALUE; TreeNode pre = null; public int g 阅读全文
摘要:
二叉树part5 654. 最大二叉树 - 力扣(LeetCode) 从中序和后序遍历构造二叉树,以及本题,这类构造树的题目,都是用前序遍历,因为先构造节点,再递归构造左子树和右子树 终止条件,注意一个叶子节点,如果为叶子节点,直接返回就可以 class Solution { public Tree 阅读全文
摘要:
二叉树part4 513. 找树左下角的值 - 力扣(LeetCode) 一眼层序遍历,最后一层的头val就是res class Solution { public int findBottomLeftValue(TreeNode root) { int res = 0; Queue<TreeNod 阅读全文