二叉树深度
来源:互联网 发布:ubuntu 如何使用汉语 编辑:程序博客网 时间:2024/06/05 01:10
class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
public class Solution {
public int TreeDepth(TreeNode root) {
int m;
int n;
if(root==null){
return 0;
}else{
m=TreeDepth(root.left);
n=TreeDepth(root.right);
if(m>n){
return m+1;
}else{
return n+1;
}
}
}
}
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
public class Solution {
public int TreeDepth(TreeNode root) {
int m;
int n;
if(root==null){
return 0;
}else{
m=TreeDepth(root.left);
n=TreeDepth(root.right);
if(m>n){
return m+1;
}else{
return n+1;
}
}
}
}
阅读全文
0 0
- 二叉树的深度
- 二叉树深度求法
- 二叉树深度算法
- 二叉树深度求法
- 二叉树的深度
- 二叉树的深度
- 二叉树的深度
- 二叉树深度
- 二叉树深度遍历
- 二叉树的深度
- 二叉树的深度
- 计算二叉树深度
- 深度遍历二叉树
- 求二叉树深度
- 二叉树的深度
- 求二叉树深度
- 二叉树的深度
- 二叉树的深度
- 【BZOJ3812】【状压DP】【容斥原理】主旋律 题解
- C#中判断线程的状态
- 使用列表组织WebView解决返回页面总是刷新的问题
- 神经网络解结构中关键部分的构造方法
- 上传大文件到linux服务器:HFS
- 二叉树深度
- View的事件分发机制
- JavaScript学习笔记
- 机器学习名词解释(train & valid & test)(accuracy & precision & recall)
- 打地鼠游戏最终版
- js中将文件的base64转换成file并上传到服务器
- mysql数据库忘记密码时如何修改
- python&Django&mariadb&Apache&mod_wsgi 环境部署
- homebrew安装及常用命令