Maximum Depth of Binary Tree
来源:互联网 发布:java图形界面步骤 编辑:程序博客网 时间:2024/05/16 14:03
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
求树的深度 深度优先搜索
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int maxDepth(TreeNode root) { if(root==null) { return 0; } { int l=maxDepth(root.left)+1; int r=maxDepth(root.right)+1; return l>r?l:r; } }}
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
- C语言的第三天
- 第八十四题 (百度面试题)
- 通向从容之道——Getting things done读书笔记
- Linux(CentOS)下,设置NAT,访问内网服务器
- 远离压力,提高效率——Getting things done读书笔记
- Maximum Depth of Binary Tree
- libGDX 模块概览
- 7.14-2014新生暑假个人排位赛01
- apt-get
- Git远程操作详解
- 让Apache Shiro保护你的应用
- 定义一个整数N,不用本地变量和循环,输入N,依次判断2N,4N,8N...,一旦大于5000,则倒序输出小于5000的那些数(...,8N,4N,2N,N)
- 黑马程序员_方法、参数、返回值及冒泡排序
- Same Tree