Loading problem…
Given the root of a binary tree, return the postorder traversal of its nodes' values.
Example 1
Input: root = [1,null,2,3]
Output: [3,2,1]
Explanation: Postorder visits left subtree, right subtree, then the node. Node 1 has only a right child 2, and 2 has only a left child 3. So 3 is visited first, then 2, then 1.
Example 2
Input: root = []
Output: []
Explanation: The tree is empty, so there is nothing to visit.
Example 3
Input: root = [1]
Output: [1]
Explanation: The only node is visited, giving [1].
Postorder visits both subtrees before the node — useful when a node's result depends on its children (e.g. deleting a tree).
Run checks all cases above. Submit evaluates all test cases.