Reverse Level Order Traversal
Level MEDIUM
Given a binary tree.Traverse the tree in the manner of reverse level order
Given a binary tree.Traverse the tree in the manner of reverse level order
Example:
Input format :
Output Format :
Constraints :
1 <= N <= 10^5
Input:
Output :
7 9 3 2 2 6 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Read input as specified in the question. | |
## Print output as specified in the question. | |
arr=list(map(int,input().split())) | |
i=len(arr)-1 | |
while i>0: | |
i=i-1 | |
if arr[i]!=-1: | |
print(arr[i],end=" ") |
Comments
Post a Comment
Please give us your valuable feedback