上善若水 大盈若冲
LeetCode link
solution
1234567891011121314151617181920212223
class Solution { public int findBottomLeftValue(TreeNode root) { Queue<TreeNode> queue = new LinkedList<>(); queue.add(root); int result = root.val; while (!queue.isEmpty()) { Queue<TreeNode> queue2 = new LinkedList<>(); TreeNode node = queue.peek(); result = node.val; while (!queue.isEmpty()) { node = queue.poll(); if (node.left != null) { queue2.add(node.left); } if (node.right != null) { queue2.add(node.right); } } queue = queue2; } return result; }}