Return the postorder traversal of a binary tree: visit left subtree, then right subtree, then the node itself.
Given the root of a binary tree, return the values of its nodes in postorder traversal.
In postorder traversal, you process each node in the following order:
Your task is to output the node values in that order.
Example 1
Input
root = [1,null,2,3]
Output
[3,2,1]
Explanation
Left subtree of 1 is empty. Visit the right subtree rooted at 2, which has left child 3. Postorder is 3, 2, 1.
Example 2
Input
root = [1,2,3,4,5,null,6]
Output
[4,5,2,6,3,1]
Explanation
Traverse left subtree of 1: postorder is 4, 5, 2. Traverse right subtree: postorder is 6, 3. Then visit 1.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.