Find Largest Value In Each Tree Row is an example of tree problems. In this post we will see how we can solve in Javascript.

Problem Description

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]

Implementation: Please check the main.js snippet for the solution. If you have different approach in mind or have any suggestion for this implementation feel free to share in the comment below. Thanks!