513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree.

Example 1:

Input:

    2
   / 
  1   3

Output:
1

Example 2: 

Input:

        1
       / 
      2   3
     /   / 
    4   5   6
       /
      7

Output:
7
题目含义:给定一个二叉树,求最底层的最左边的值
 1     public int findBottomLeftValue(TreeNode root) {
 2        Queue<TreeNode> q = new LinkedList<>();
 3        q.add(root);
 4        while (!q.isEmpty())
 5        {
 6            root = q.poll();
 7            if (root.right !=null) q.offer(root.right);
 8            if (root.left !=null) q.offer(root.left);
 9        }
10        return root.val;     
11     }
原文地址:https://www.cnblogs.com/wzj4858/p/7711893.html