New update is available. Click here to update.
Close
Topic list
Reverse Level Order Traversal
MEDIUM
30 mins
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Reverse Level Order Traversal

Contributed by
Ekansh Saxena
Medium
0/80
Avg time to solve 30 mins
Success Rate 52 %
Share

## Problem Statement

#### You have been given a Binary Tree of integers. You are supposed to return the reverse of the level order traversal.

##### For example:
``````For the given binary tree
``````

``````The reverse level order traversal will be {7,6,5,4,3,2,1}.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
``````
##### Sample Output 1:
``````7 6 5 4 3 2 1
``````
##### Explanation of Sample Input 1:
``````Start with the bottom of the tree, i.e. 7, and traverse in the tree in the reverse direction of level order, i.e., bottom to top and right to left. So, the reverse level order traversal will be {7,6,5,4,3,2,1}.
``````
##### Sample Input 2:
``````2 7 5 2 6 -1 9 -1 -1 5 11 4 -1 -1 -1 -1 -1 -1 -1
``````
##### Sample Output 2:
``````4 11 5 9 6 2 5 7 2
``````
##### Explanation of Sample Input 2:
``````Traverse the tree in the reverse direction of level order, i.e., bottom to top and right to left. So reverse level order traversal will be {4,11,5,9,6,2,5,7,2}.
``````
Auto
Console