Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Postorder Traversal of Binary Tree

XPChallenge Points: 10
levelLevel: Easy

You are given the root of a binary tree.
Return a list of node values when you visit the tree in postorder:


1. Visit left subtree
2. Visit right subtree
3. Visit the node itself

Example 1:

Input: tree = [10, null, 20, 15]

Output: [15, 20, 10]

Explanation:

Left subtree of 10 is empty → right subtree is 20 → left child of 20 is 15. Order: 15 → 20 → 10.

Example 2:

Input: tree = [5, 3, 8, 1, 4, 7, 9]

Output: [1, 4, 3, 7, 9, 8, 5]

Explanation:

Visit left branch fully first (1,4,3), then right branch (7,9,8), finally root 5.

Example 3:

Input: tree = []

Output: []

Explanation:

No nodes to visit.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result