Skip to content
C

Level Order Traversal

Easyjavapythonccppjavascript

Given a binary tree in level-order form, print its nodes level by level from top to bottom, one level per line.

Input Format

The first line contains an integer M, the number of level-order tokens. The second line contains M space-separated tokens (integers or null). It is blank when M is 0.

Output Format

For each level from the root downward, print the values on that level separated by single spaces, one level per line. Print nothing for an empty tree.

Input (stdin)

Output

Run your code to see output here...