1. 程式人生 > >LintCode 68---Binary Tree Postorder Traversal

LintCode 68---Binary Tree Postorder Traversal

eno void ger () init nbsp order contain ont

/**
 * Definition of TreeNode:
 * public class TreeNode {
 *     public int val;
 *     public TreeNode left, right;
 *     public TreeNode(int val) {
 *         this.val = val;
 *         this.left = this.right = null;
 *     }
 * }
 */

public class Solution {
    /**
     * @param root: A Tree
     * 
@return: Postorder in ArrayList which contains node values. */ List<Integer> list = new ArrayList<>(); public List<Integer> postorderTraversal(TreeNode root) { hou(root); return list; } public void hou(TreeNode root) { if(root == null
) { return; } hou(root.left); hou(root.right); list.add(root.val); } }

LintCode 68---Binary Tree Postorder Traversal