maximum-depth-of-binary-tree
来源:互联网 发布:知天气福建版 数值预报 编辑:程序博客网 时间:2024/06/08 10:19
题目:
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.
程序:
class Solution {public: int maxDepth(TreeNode *root) { if(root==NULL) return 0; int h1=0,h2=0; if(root->left) h1=maxDepth(root->left); if(root->right) h2=maxDepth(root->right); return h1>h2?h1+1:h2+1; }};
阅读全文
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
- 关于移动端H5横竖屏问题
- Nginx的启动、停止与重启
- 鼠标事件移入移出的比较
- Hbuilder配置逍遥安卓等android第三方虚拟机
- HTML5、CSS3实现旋转特效
- maximum-depth-of-binary-tree
- background-size中,100%和cover的区别
- Windows 下音频数据采集和播放
- 文本文件与其他二进制文件的区别
- 关于mybatis两种连接mysql的方式(注解和xml配置)
- android adt 网络请求
- 在OpenCV环境下进行图像的直方图均衡化
- web------下拉菜单
- SDDCaaS