589. N叉树的前序遍历
难度简单114
给定一个 N 叉树,返回其节点值的前序遍历。
例如,给定一个 3叉树 :

返回其前序遍历: [1,3,5,6,2,4]。
class Solution {List<Integer> res =new ArrayList<Integer>();public List<Integer> preorder(Node root) {if(root==null){return res;}helper(root);//v1return res;}public void helper(Node root){res.add(root.val);for(Node child:root.children){helper(child);}//return res;//v1}}
