@@ -0,0 +1,1250 @@
+/**%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 * Complexity: O(N) time and space%0A */%0Apublic class Solution %7B%0A  public List%3CInteger%3E largestValues(TreeNode root) %7B%0A    List%3CInteger%3E list = new ArrayList%3CInteger%3E();%0A    if (root == null) return list;%0A%0A    // Using BFS%0A    Queue%3CTreeNode%3E queue = new LinkedList%3CTreeNode%3E();%0A    queue.add(root);%0A%0A    // Counters for keeping track of depth.%0A    int cur = 1;%0A    int next = 0;%0A%0A    // The current max for the current depth.%0A    int max = Integer.MIN_VALUE;%0A%0A    while (!queue.isEmpty()) %7B%0A      TreeNode node = queue.poll();%0A      // Always update the max.%0A      max = Math.max(max, node.val);%0A      cur --;%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      // The end of the level/depth has been reached%0A      // so update all counters and add the current max as well as resetting the max.%0A      if (cur == 0) %7B%0A        list.add(max);%0A        max = Integer.MIN_VALUE;%0A        cur = next;%0A        next = 0;%0A      %7D%0A    %7D%0A%0A    return list;%0A  %7D%0A%7D%0A

Add leetcode 515 :smile: