#C787. Left View of a Binary Tree

    ID: 51788 Type: Default 1000ms 256MiB

Left View of a Binary Tree

Left View of a Binary Tree

You are given a binary tree and your task is to print its left view.

The left view of a binary tree is defined as the set of nodes visible when the tree is viewed from the left side. Formally, for each level \(i\) of the tree, the left view contains the first node encountered in that level.

Example:

Input: 1 2 3 4 5 6 7 8 N N N N N N N
Output: 1 2 4 8

Note that the input is provided in level order where the missing nodes are denoted by N (representing \(null\)).

inputFormat

The input is given via standard input (stdin) as a single line containing space-separated tokens representing the nodes of the binary tree in level order. Use N to denote a missing node.

For example:

1 2 3 4 N 6 7 8 N N N N N N N

outputFormat

Print the left view of the binary tree as a single line of space-separated integers to standard output (stdout).

## sample
1 2 3 4 5 6 7 8 N N N N N N N
1 2 4 8