104 Maximum Depth of Binary Tree
来源:互联网 发布:节流装置计算软件 编辑:程序博客网 时间:2024/05/17 04:08
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; int l=maxDepth(root->left); int r=maxDepth(root->right); return l>r?l+1:r+1; }};
0 0
- Leetcode 104 Maximum Depth of Binary Tree
- LeetCode(104)Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- LeetCode: Maximum Depth of Binary Tree [104]
- Leetcode(104)Maximum Depth of Binary Tree
- [leetcode 104] Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- leetCode #104 Maximum Depth of Binary Tree
- LeetCode 104: Maximum Depth of Binary Tree
- 104Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- leetcode || 104、Maximum Depth of Binary Tree
- LeetCode 104: Maximum Depth of Binary Tree
- leetcode[104]:Maximum Depth of Binary Tree
- Leetcode[104]-Maximum Depth of Binary Tree
- Leetcode---(104)Maximum Depth of Binary Tree
- leetcode-104-Maximum Depth of Binary Tree
- #104 Maximum Depth of Binary Tree
- 编译Linux内核
- TableLayout 佈局介紹
- 文章标题
- iOS开发-UIWebView加载本地和网络数据
- hdu1028 Ignatius and the Princess III 递推
- 104 Maximum Depth of Binary Tree
- ios图片添加水印
- N通道Float 差值算法
- OCP(02).安装Oracle11g
- av格式
- 写文件和读文件
- iOS 开发编程你需要知道的知识(不定期更新) —— HERO博客
- BZOJ 4567: [Scoi2016]背单词
- Mac装less环境