import java.util.*;
/*
* public class TreeNode {
* int val = 0;
* TreeNode left = null;
* TreeNode right = null;
* public TreeNode(int val) {
* this.val = val;
* }
* }
*/
public class Solution {
List<Integer> list = new ArrayList<>();
public void postorder(TreeNode root) {
if (root == null)
return;
postorder(root.left);
postorder(root.right);
list.add(root.val);
}
public int[] postorderTraversal(TreeNode root) {
postorder(root);
int[] post = new int[list.size()];
for (int i = 0; i < post.length; i++) {
post[i] = list.get(i);
}
return post;
}
}