第一次看到accept,心里有点小开心
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { void show(List<Integer> li,TreeNode p){ if(p!=null){ li.add(p.val); show(li,p.left); show(li,p.right); } } public List<Integer> preorderTraversal(TreeNode root) { List<Integer> li = new ArrayList<Integer>(); show(li,root); return li; } }
Binary Tree Preorder Traversal,布布扣,bubuko.com
Binary Tree Preorder Traversal
原文:http://www.cnblogs.com/HeyJuice/p/3778987.html