Solution Review: nth Post-Order
Let’s go through the detailed solution review of the challenge given in the previous lesson.
We'll cover the following
Solution
We’ll make a counter to keep track of our index. Because we want to print the node that is at the index in post-order traversal, we’ll increment after we traverse the left child and right child. When the counter becomes equal to the index, we’ll print the value and return the post-order index node.
Solution code
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.