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]
- Depth-first or Breadth-first search: O(n) - complexity, O(h) - memory if using stack or queue
- DFS using std::stack solution
- BFS using std::queue solution
- Solution with std::map