Maximum Depth of Binary Tree 树的最大深度
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
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int maxDepth(TreeNode *root) {
if(root==NULL)
return ;
int i=maxDepth(root->left)+;
int j=maxDepth(root->right)+;
return max(i,j);
}
};
Maximum Depth of Binary Tree 树的最大深度的更多相关文章
- [LintCode] Maximum Depth of Binary Tree 二叉树的最大深度
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- [LeetCode] Maximum Depth of Binary Tree 二叉树的最大深度
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- [LeetCode] 104. Maximum Depth of Binary Tree 二叉树的最大深度
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- [Leetcode] Maximum depth of binary tree二叉树的最大深度
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- LeetCode 104. Maximum Depth of Binary Tree二叉树的最大深度 C++/Java
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- [LeetCode] 104. Maximum Depth of Binary Tree ☆(二叉树的最大深度)
描述 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the l ...
- LeetCode OJ:Maximum Depth of Binary Tree(二叉树最大深度)
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- leetCode 104.Maximum Depth of Binary Tree(二叉树最大深度) 解题思路和方法
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- Maximum Depth of Binary Tree(二叉树最大深度)
来源:https://leetcode.com/problems/maximum-depth-of-binary-tree Given a binary tree, find its maximum ...
随机推荐
- LRU Cache数据结构简介
什么是LRU Cache LRU是Least Recently Used的缩写,意思是最近最少使用,它是一种Cache替换算法. 什么是Cache?狭义的Cache指的是位于CPU和主存间的快速RAM ...
- DVWA 之medium级别sql注入
中级注入的提交方式从get请求改为post请求,可以用burp抓包注入或抓注入点 1 . 判断是否有注入 sqlmap -u "http://192.168.242.1/dvw/vulne ...
- 【DM8168学习笔记5】EZSDK目录结构
EZSDK5.02的目录结构与之前的版本不同,之前的版本各个组件都放在/ezsdk目录下,5.02做了整合. 之前版本:(图片摘自:3.DM816x_1-day_Workshop-Getting_St ...
- 《2018年云上挖矿态势分析报告》发布,非Web类应用安全风险需重点关注
近日,阿里云安全团队发布了<2018年云上挖矿分析报告>.该报告以阿里云2018年的攻防数据为基础,对恶意挖矿态势进行了分析,并为个人和企业提出了合理的安全防护建议. 报告指出,尽管加密货 ...
- loading遮罩
.loading{ position: relative; cursor: default; point-events: none; text-shadow: none!important; colo ...
- MAC+iTerm定制目录显示颜色和提示符
知道该如何定制ls时各种类型文件(unix下所有的都是file..)的颜色了. 很简单,就是在.bash_profile下加了三行. export CLICOLOR=1 export LSCOLORS ...
- OCR Tesseract 识别报 empty page解决办法
图片分辨率太低导致 周边加空白 然后重新操作,就行了
- hibernate 查询最大值(数据条目数)
如下 使用 SELECT COUNT(*) 然后获取最大值 Integer.parseInt(query.list().).toString()); 比如 StringBuffer hql1; hql ...
- 使用session实现一次性验证码
在登录页面和各种页面,会看到有验证码输入,这样做的目的是为了防止密码猜测工具破解密码,保护了用户密码安全,验证码只能使用一次,这样就给密码猜测工具带来了很大的困难,基本上阻断了密码猜测工具的使用. 可 ...
- python实例 函数
#! /usr/bin/python # -*- coding: utf8 -*- def sum(a,b): return a+b func = sum r = func(5,6) prin ...