题目描述
题目链接:https://leetcode.cn/problems/binary-tree-postorder-traversal/description/
代码实现
class Solution {
List<Integer> tree = new ArrayList<>();
public List<Integer> postorderTraversal(TreeNode root) {
postorder(root);
return tree;
}
public void postorder(TreeNode root){
if(root==null){
return;
}
postorder(root.left);
postorder(root.right);
tree.add(root.val);
}
}