LeetCode OJ Maximum Depth of Binary Tree
来源:互联网 发布:理解信息与数据 编辑:程序博客网 时间:2024/06/13 01:15
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) { max = 0; now = 0; if (root != NULL) gogogo(root); return max; } void gogogo(TreeNode *nowRoot) { now++; if (nowRoot->left != NULL) gogogo(nowRoot->left); if (nowRoot->right != NULL) gogogo(nowRoot->right); if (nowRoot->left == NULL && nowRoot->right == NULL) max = max > now ? max : now; now--; } int now; int max;};
0 0
- [LeetCode OJ]Maximum Depth of Binary Tree
- LeetCode OJ:Maximum Depth of Binary Tree
- LeetCode OJ - Maximum Depth of Binary Tree
- [LeetCode OJ]Maximum Depth Of Binary Tree
- LeetCode OJ Maximum Depth of Binary Tree
- <LeetCode OJ> (104 / 111) Maximum & Minimum Depth of Binary Tree
- LeetCode OJ : 104. Maximum Depth of Binary Tree
- LeetCode oj 104. Maximum Depth of Binary Tree(DFS||BFS)
- Leetcode - Tree - Maximum Depth of Binary Tree
- [leetcode][tree] Maximum Depth of Binary Tree
- LeetCode Maximum Depth of Binary Tree
- [Leetcode] Maximum Depth of Binary Tree
- leetcode 24: Maximum Depth of Binary Tree
- [LeetCode] Maximum Depth of Binary Tree
- Leetcode 104 Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- [LeetCode]Maximum Depth of Binary Tree
- opencv一些函数的使用
- LeetCode OJ Same Tree
- LeetCode OJ Minimum Depth of Binary Tree
- Python 编码知识学习笔记
- 网站架构的演变过程
- LeetCode OJ Maximum Depth of Binary Tree
- CSS3 弹性盒布局说明(CSS3 Flexible Box Layout Explained)
- LeetCode OJ Word Break
- 自己写一个简单的Web服务器(附Demo)
- (转)Hbase访问方式之Mapreduce
- 多动画集在D3D下的渲染
- uva 10029 HASH + DP
- UVALive - 4015 Caves 树形DP
- LeetCode OJ Binary Tree Preorder Traversal