1
2
3
4
5
6
7
8
9
10
11
12
|
public List<Integer> ans = new ArrayList<>();
public List<Integer> postorderTraversal(TreeNode root){
postorder(root);
return ans;
}
public void postorder(TreeNode node) {
if(node == null) return;
postorder(node.left);
postorder(node.right);
ans.add(node.val);
}
|