LeetCode 513.找树左下角的值 分析1.0 二叉树的 最底层 最左边 节点的值,层序遍历获取最后一层首个节点值,记录每一层的首个节点,当没有下一层时,返回这个节点 class Solution { ArrayDeque<TreeNode> queue = new ArrayDeque(); int res = 0; public int findBottomLeftValue(TreeNode root) { queue.offer(root); return levelOrder(…
LeetCode 110.平衡二叉树 分析1.0 求左子树高度和右子树高度,若高度差>1,则返回false,所以我递归了两遍 class Solution { public boolean isBalanced(TreeNode root) { if(root == null){ return true; } int left = postOrder(root.left); int right = postOrder(root.right); if(Math.abs(left-right)>1…