#K53042. Bottom-Up Level Order Traversal of a Binary Tree

    ID: 29443 Type: Default 1000ms 256MiB

Bottom-Up Level Order Traversal of a Binary Tree

Bottom-Up Level Order Traversal of a Binary Tree

Given a binary tree, your task is to perform a bottom-up level order traversal. In other words, traverse the tree level by level, starting from the bottom-most level and moving up to the root node.

The binary tree is represented in level order serialization, where missing nodes are denoted by the word null. For example, the tree $$ \begin{array}{c} 1 \\ / \\ 2 3 \\ / \ / \\ 4 5 6 7 \end{array} $$ can be serialized as 1 2 3 4 5 6 7 and its bottom-up level order traversal is $$4\,5\,6\,7\,2\,3\,1.$$

Your program should read the tree representation from the standard input (stdin) and output the bottom-up traversal as a sequence of integers separated by a single space to the standard output (stdout).

inputFormat

The input is provided via standard input (stdin) as a single line containing space-separated tokens representing the tree in level order.

Each token is either an integer or the string null indicating a missing node.

For example:
1 2 3 4 5 6 7

outputFormat

Output the node values of the binary tree in a single line via standard output (stdout), representing the bottom-up level order traversal with each value separated by a space.

## sample
1
1