1 Star 0 Fork 0

表情扭曲 / leetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc589.java 780 Bytes
一键复制 编辑 原始数据 按行查看 历史
liu13 提交于 2019-05-15 13:42 . 20190515
package code;
import java.util.ArrayList;
import java.util.List;
/*
* 589. N-ary Tree Preorder Traversal
* 题意:多叉树先序遍历
* 难度:Easy
* 分类:Tree
* 思路:
* Tips:
*/
public class lc589 {
class Node {
public int val;
public List<Node> children;
public Node() {}
public Node(int _val,List<Node> _children) {
val = _val;
children = _children;
}
}
List<Integer> res;
public List<Integer> preorder(Node root) {
res = new ArrayList<>();
helper(root);
return res;
}
public void helper(Node root){
if(root==null) return;
res.add(root.val);
for(Node nd:root.children){
helper(nd);
}
}
}
1
https://gitee.com/abfantasy/leetcode.git
git@gitee.com:abfantasy/leetcode.git
abfantasy
leetcode
leetcode
master

搜索帮助