1 Star 0 Fork 0

表情扭曲 / leetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc559.java 738 Bytes
一键复制 编辑 原始数据 按行查看 历史
liu13 提交于 2019-05-15 13:42 . 20190515
package code;
import java.util.List;
/*
* 559. Maximum Depth of N-ary Tree
* 题意:多叉树的最大深度
* 难度:Easy
* 分类:Tree, Depth-first Search, Breadth-first Search
* 思路:BFS 也能做和 lc104思路一样
* Tips:lc104, lc111
*/
public class lc559 {
class Node {
public int val;
public List<Node> children;
public Node() {}
public Node(int _val,List<Node> _children) {
val = _val;
children = _children;
}
}
public int maxDepth(Node root) {
if(root==null) return 0;
int res = 0;
for (Node nd : root.children) {
res = Math.max(maxDepth(nd), res);
}
return res+1;
}
}
1
https://gitee.com/abfantasy/leetcode.git
git@gitee.com:abfantasy/leetcode.git
abfantasy
leetcode
leetcode
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891