144. 二叉树的前序遍历
作者:互联网
class Solution {
List list = new LinkedList();
public List<Integer> preorderTraversal(TreeNode root) {
if (root == null) {
return list;
}
list.add(root.val);
preorderTraversal(root.left);
preorderTraversal(root.right);
return list;
}
}
https://leetcode-cn.com/problems/binary-tree-preorder-traversal/
标签:144,return,preorderTraversal,List,前序,list,二叉树,root 来源: https://www.cnblogs.com/taoyuann/p/15472766.html