Maximum Depth of Binary Tree
来源:互联网 发布:apache tools 编辑:程序博客网 时间:2024/06/07 01:34
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==0) 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
- 网站优化只之纯文本链接的作用-四川土豪工作室
- 智能监控系统开发
- POJ 1061青蛙的约会 ,扩展欧几里得算法
- SQL插入数据的几种方式
- gcc编译器完全优化指南
- Maximum Depth of Binary Tree
- LeetCode 071-Simplify Path
- jQuery验证控件jquery.validate.js使用说明+中文API
- leetcode025:Reverse Nodes in k-Group
- 解题报告 之 POJ3189 Steady Cow Assignment
- 网络学习的网址
- c的多维数组动态建立的问题
- JVM 配置参数学习与研究
- python34之殇——DJango连接Mysql数据库