Maximum Depth of Binary Tree
来源:互联网 发布:baocms7.1完整源码 编辑:程序博客网 时间:2024/06/06 00:26
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 a binary tree node. * 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 0; return max(maxDepth(root->left),maxDepth(root->right))+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
- 【排序算法】堆排序
- OpenCv下的xml文件在matlab下的读入
- Intellij idea插入表数据【在UI界面插入出错】
- Java + Spark SQL + Hive + Maven简单实现和异常问题
- 【OpenGL ES】OpenGL ES简介
- Maximum Depth of Binary Tree
- Javascript 数据直接量
- python sklearn机器学习库 安装 及 2个spyder的安装
- 程序设计基础(C)大作业——学籍管理系统(1)
- 【面试题】剑指offer03--判断一个数是否在一个二维数组中
- 推荐资源:sound-of-sorting-0.6.5.exe
- JavaScript简介
- js之【窗口事件和event对象】(有一个追踪鼠标定位的小栗子)
- anaconda下安装scrapy连接mysql