less than 1 minute read

Given a binary tree root, return the leftmost node’s value on each level of the tree.

Constraints

  • n ≤ 100,000 where n is the number of nodes in root

https://binarysearch.com/problems/Left-Side-View-of-a-Tree

Examples

Example 1

Input

  • root =

Output

  • answer = [0, 5, 1]

Solution

Leave a comment