1、用队列进行处理。分别找到每一行中的最大值。 public List<Integer> largestValues(TreeNode root) {List<Integer> result = new ArrayList<>();if(root == null) {return result;}Queue<TreeNode> queue = new LinkedList<>();queu
You need to find the largest value in each row of a binary tree. Example: Input: 1/ \3 2/ \ \ 5 3 9 Output: [1, 3, 9] 广度优先搜索用队列,深度优先搜索用堆栈(还有,程序第三行在eclipse中会报错,leetcode上可以运行) pub