Challenge: Print Spiral Tree

Let’s print a binary tree in spiral order.

Problem

Given a binary tree, print the nodes breadth-first in spiral order.

Input

A binary tree.

Output

Display a breadth-first spiral order traversal of the tree on the console.

Sample input

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.