Maximum Depth of Binary Tree——Difficulty:Easy
来源:互联网 发布:广电网络用什么机顶盒 编辑:程序博客网 时间:2024/06/05 08:01
Problem :
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.
Example:
**
Algorithm:
**
水题水一下。。。
**
Code:
/** * 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)+1,maxDepth(root->right)+1); }};
0 0
- Maximum Depth of Binary Tree——Difficulty:Easy
- Leet Code OJ 104. Maximum Depth of Binary Tree [Difficulty: Easy]
- Maximum Depth of Binary Tree(easy)
- 104. Maximum Depth of Binary Tree (Easy)
- LeetCode104—Maximum Depth of Binary Tree
- LeetCode刷题(C++)——Maximum Depth of Binary Tree(Easy)
- 【leetcode】【Easy】【104. Maximum Depth of Binary Tree】【tree】
- [Leetcode 104, Easy] Minimum (Maximum) Depth of Binary Tree
- 【LeetCode】(104)Maximum Depth of Binary Tree(Easy)
- Leetcode----104. Maximum Depth of Binary Tree(easy)
- 104. Maximum Depth of Binary Tree [easy] (Python)
- Easy-题目3:104. Maximum Depth of Binary Tree
- Leetcode 104. Maximum Depth of Binary Tree (Easy) (cpp)
- Easy 104题 Maximum Depth of Binary Tree
- LeetCode #104 - Maximum Depth of Binary Tree - Easy
- LeetCode解题报告 104. Maximum Depth of Binary Tree [easy]
- 【Leetcode-easy-104】Maximum Depth of Binary Tree
- LeetCode-Easy刷题(21) Maximum Depth of Binary Tree
- sed 匹配最短模式的方法
- 前端代码规范V1.0
- iOS---Xcode中删除描述文件Provisioning Profiles
- 结构体数组 循环显示成员
- java内存溢出和内存泄露
- Maximum Depth of Binary Tree——Difficulty:Easy
- 正确的设置UIView的frame
- PHP Ajax 跨域问题最佳解决方案
- js 静态私有变量
- 几行代码快速集成二维码扫描库
- 用汇编得到变量地址
- Android视频播放器开发—— 探究MediaPlayer
- The Skyline Problem解题报告
- 简单的多线程实例C++