You are given the root of a binary tree. Your task is to return the postorder traversal of the tree.
Input: root = [1,null,2,3]
Output: [3,2,1]
Explanation: The nodes are visited in Left → Right → Root order.
Input: root = [1,2,3]
Output: [2,3,1]
Explanation: The left subtree is visited first, followed by the right subtree and the root.
Input: root = []
Output: []
Explanation: The tree is empty.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
1 2 3 4 5 6 7
4 5 2 6 7 3 1
10 5 15 2 7 12 20
2 7 5 12 20 15 10