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/