Maximum Depth of Binary Tree 二叉树的最大深度
来源:互联网 发布:网络平台赌博游戏代理 编辑:程序博客网 时间:2024/04/29 21:21
Maximum Depth of Binary Tree
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==NULL) return 0; int left=0,right=0; left=maxDepth(root->left); right=maxDepth(root->right); return (left>right?left: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(二叉树的最大深度)
- 【LeetCode】Maximum Depth of Binary Tree (二叉树最大深度)
- Leetcode Maximum Depth of Binary Tree 二叉树最大深度
- Maximum Depth of Binary Tree--二叉树的深度
- 104. Maximum Depth of Binary Tree | 二叉树的深度
- 求二叉树的最大深度 Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree 二叉树的最大深度(重)
- LeetCode OJ 之 Maximum Depth of Binary Tree (二叉树的最大深度)
- [leetcode]Maximum Depth of Binary Tree (求二叉树的最大深度 C语言)
- LinCode Maximum Depth of Binary Tree 二叉树的最大深度
- leetcode系列(28)Maximum Depth of Binary Tree 求二叉树的最大深度
- Maximum Depth of Binary Tree --- 求二叉树的最大深度
- LeetCode 104 Maximum Depth of Binary Tree(二叉树的最大深度)
- [Java代码] [Leetcode] Maximum and Minimum Depth of Binary Tree 二叉树的最小最大深度
- 3D效果-HTML+CSS
- hdu 1267 下沙的沙子有几粒?(卡特兰数 与1134思路相同)
- Binary Tree Level Order Traversal 二叉树按层遍历
- 【ASP】Win7环境下IIS的配置
- [汇文教育]iOS内支付(IAP)研究
- Maximum Depth of Binary Tree 二叉树的最大深度
- MySQl命令
- mongodb 增加管理员及普通用户
- VC对话框大小和位置设置
- Binary Tree Level Order Traversal II 从下向上按层遍历二叉树
- A program to compute word length of a machine
- iOS中动画实现技术主要是:Core Animation。
- [csu oj]1553: Good subsequence(水题)
- Coursera上Andrew Ng机器学习课程总结(一)