#C8370. Binary Tree Level Order Traversal

    ID: 52345 Type: Default 1000ms 256MiB

Binary Tree Level Order Traversal

Binary Tree Level Order Traversal

Given a binary tree, your task is to output its level order (breadth-first) traversal. The binary tree is provided as a single line of input representing the node values in level order, where the keyword null represents a missing node.

Your solution should output the node values in level order as a space-separated sequence. For example, given the binary tree represented by the input 1 2 3, the expected output is 1 2 3.

Assume that the number of nodes in the tree is between \(1\) and \(10^4\), and each node's value is an integer.

inputFormat

The input is read from stdin as a single line containing the binary tree nodes in level order, separated by spaces. Use the keyword null to denote a missing node. For example, the input 1 2 3 null 4 represents a tree with root 1, left child 2, right child 3, and a left child 4 for node 2.

outputFormat

Output the level order traversal of the binary tree as a space-separated sequence of integers to stdout. If the tree is empty, output an empty line.

## sample
1
1

</p>