Problem
You need to find the largest value in each row of a binary tree.
Example
1 | Input: |
Solution1
Method: Breadth-first Search
Time Complexity: O(n)
Space Complexity:
1 | # Definition for a binary tree node. |
Solution2
Method: Depth-first Search
Time Complexity: O(n)
Space Complexity:
1 | class Solution: |