Challenge: nth Post-order

Let’s print the value present in the nth node when traversing a tree in post-order

Problem

Given a binary tree, print the value of nodes that will be at the nthn^{th} index when the tree is traversed in post-order.

Input

An integer index.

Output

Display the value of the node at the given index in post-order traversal.

Sample input

index = 5

Sample output

5

Let’s look at the illustration to better understanding the problem.

Get hands-on with 1400+ tech skills courses.