Find Bottom Left Tree Value
给一个二叉树, 返回左下的节点的值, 直接层序扫描, 然后最后一层的第一个值肯定就是啦.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class Solution { public int findBottomLeftValue(TreeNode root) { int res = 0; Queue<TreeNode> q = new ArrayList<>(); q.offer(root); while(!q.isEmpty()) { int size = q.size(); for(int i = 0; i < size; i++) { if(i == 0) { res = q. } } } } } |