@@ -0,0 +1,1460 @@
+/**%0A * Definition for a binary tree node.%0A * public class TreeNode %7B%0A *     int val;%0A *     TreeNode left;%0A *     TreeNode right;%0A *     TreeNode(int x) %7B val = x; %7D%0A * %7D%0A *%0A * Given a binary tree, find the leftmost value in the last row of the tree.%0A *%0A * Solution:%0A * Use bfs to reach every node.%0A * Use different counters/variables to keep track of the first/left most node in every level.%0A * Complexity: O(n) time and space where n is the # of nodes in the tree.%0A */%0Apublic class Solution %7B%0A    public int findBottomLeftValue(TreeNode root) %7B%0A        Queue%3CTreeNode%3E queue = new LinkedList%3CTreeNode%3E();%0A        int current = 1;%0A        int next = 0;%0A        int left = root.val;%0A        int childCount = -1;%0A        queue.add(root);%0A        %0A        while (!queue.isEmpty()) %7B%0A            TreeNode node = queue.poll();%0A            if (next == 0 && ((current %3E 1 && current == childCount) %7C%7C (current == 1 && childCount == 1))) %7B%0A                left = node.val;%0A            %7D%0A            current --;%0A            %0A            if (node.left != null) %7B%0A                queue.add(node.left);%0A                next ++;%0A            %7D%0A            %0A            if (node.right != null) %7B%0A                queue.add(node.right);%0A                next ++;%0A            %7D%0A            %0A            if (current == 0) %7B%0A                current = next;%0A                childCount = next;%0A                next = 0;%0A            %7D%0A        %7D%0A        %0A        return left;%0A    %7D%0A%7D%0A

Add leetcode #513