Maximum Depth of Binary Tree
来源:互联网 发布:赌博平台完整源码 编辑:程序博客网 时间:2024/06/17 14:11
public class Solution {public static void main(String[] args) {// TODO Auto-generated method stub}public int maxDepth(TreeNode root) { if(root == null) return 0; int left = depth(root.left); int right = depth(root.right); return Math.max(left, right)+1; }public int depth(TreeNode node)//得到左右子树的最大深度{if(node == null)return 0;int leftdepth = depth(node.left);int rightdepth = depth(node.right);return Math.max(leftdepth, rightdepth)+1;}}class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; }}
0 0
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- truncate与delete的区别
- PyQt5教程-22-自定义控件
- 栈的简单应用(初学)
- Android中引导页
- margin 1\2\3\4参数意义
- Maximum Depth of Binary Tree
- 逆元详解
- 使用mybatis生成配置文件bean、xml、dao
- java IO (二)字符流与字节流
- 数据库中DDL、DML、DCL和TCL概念
- spring的事务处理机制
- poj 1426 Find The Multiple
- 招募创业伙伴七大建议:态度高于能力
- 理解数据库事务隔离级别以及脏读, 不可重复读, 幻读