515.Find-Largest-Value-in-Each-Tree-Row

515. Find Largest Value in Each Tree Row

题目地址

https://leetcode.com/problems/find-largest-value-in-each-tree-row/

题目描述

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]

代码

Approach #1 DFS with depth

Approach #2 BFS

Last updated

Was this helpful?